ViewVC Help
View File | Revision Log | View Changeset | Root Listing
root/Oni2/Daodan/src/Flatline.c
(Generate patch)

Comparing Daodan/src/Flatline.c (file contents):
Revision 485 by gumby, Fri Dec 11 08:58:07 2009 UTC vs.
Revision 486 by gumby, Sun Dec 13 11:01:21 2009 UTC

# Line 288 | Line 288 | bool FLrClient_Run(flatline_packet* pack
288                          player_data * data = (void*)packet->data;
289                          uint16_t i = data->PlayerNum;
290                          //DDrConsole_PrintF("Got data for Player %i, %x", i, PlayerList[i]);
291 <                        if (!PlayerList[i] || i > max_connections) break;
292 <                        PlayerList[i]->Chr = ((GameState *)ONgGameState)->CharacterStorage;
291 >                        if (i > max_connections || PlayerList[i] == 0) break;
292 >                        
293 >                        //PlayerList[i]->Chr = ((GameState *)ONgGameState)->CharacterStorage;
294 >                        
295                          PlayerList[i]->Chr->Health = data->Health;
296                          PlayerList[i]->Chr->MaxHealth = data->MaxHealth;
297                          PlayerList[i]->Chr->Position = data->Position;
# Line 301 | Line 303 | bool FLrClient_Run(flatline_packet* pack
303                          PlayerList[i]->Actions1 = data->Inputs.Actions1;
304                          PlayerList[i]->Actions2 = data->Inputs.Actions2;
305                          ActiveCharacter * Active = ((ActiveCharacter*)(ONrGetActiveCharacter(PlayerList[i]->Chr)));
306 +                        if(!Active) break;
307                          
305                        //needs special case for jumping\possibly falling characters
308                          Active->PhyContext_->Position = data->Position;
309                          
310 <                        //antilag, lol.
311 <                        if((int)*((char*)(Active + 0x1AF8) + 0x166) > data->Frame)
312 <                        *(uint16_t *)((char*)Active + 0x1C88) = data->Frame;
310 >                        /*
311 >                        int ptr = 0;
312 >                        (TMrInstance_GetDataPtr('TRAM',data->Animation,&ptr)); *(void**)((char*)Active + 0x1AF8) = ptr;
313 >                                                
314 >                        *(uint16_t *)((char*)Active + 0x1AFC) = data->AnimationToState;
315 >                        *(uint16_t *)((char*)Active + 0x1AFE) = data->AnimationFromState;
316 >                        *(uint16_t *)((char*)Active + 0x1B00) = data->AnimationType;
317 >                        *(uint16_t *)((char*)Active + 0x1B02) = data->NextAnimationType;
318 >                        *(uint16_t *)((char*)Active + 0x1B04) = data->AnimationType2;
319 >                        */
320 >                        if((int)*((char*)(Active + 0x1AF8) + 0x166) > data->Frame + 1)
321 >                        *(uint16_t *)((char*)Active + 0x1C88) = data->Frame + 1;
322 >                                
323                          break;
324                  default:
325                          DDrConsole_PrintF("Warning, recieved badly formed packet!");
# Line 377 | Line 389 | void * ONICALL FLrInput_Update_Keys(void
389                  return ONgGameState;
390          }
391   #endif
392 <        if(!server_started) return ONgGameState;
392 >        if(!(server_started || client_connected)) return ONgGameState;
393          uint16_t i;
394          for(i = 0; i < max_connections; i++) {
395 <                if(!PlayerList[i]) continue;
395 >                if(PlayerList[i] == 0) continue;
396                  char * Active_Player = (void*)ONrGetActiveCharacter(PlayerList[i]->Chr);
397 <                if(!Active_Player) return ONgGameState;
397 >                
398 >                if(Active_Player == 0) continue;
399                  GameInput * Active_Input = (void*)( Active_Player + 0x2158);
400 <                        
400 >                if(server_started) {
401                          flatline_packet data_out = {0};
402                          data_out.id = PLAYER_DATA;
403                          player_data * data = (void*)&(data_out.data);
# Line 398 | Line 411 | void * ONICALL FLrInput_Update_Keys(void
411                          data->DesiredFacing = PlayerList[i]->Chr->DesiredFacing;
412                          data->CosmeticFacing = PlayerList[i]->Chr->CosmeticFacing;
413                          data->Frame = *(Active_Player + 0x1C88);
414 <                        data->Inputs.Actions1 = PlayerList[i]->Actions1;
415 <                        data->Inputs.Actions2 = PlayerList[i]->Actions2;
416 <
417 <                        if(!server_started || i != 0 ) {
414 >                        memcpy(data->Animation, TMrInstance_GetInstanceName(*(void **)(Active_Player + 0x1AF8)), 32);
415 >                        data->AnimationToState = *(uint16_t *)(Active_Player + 0x1AFC);
416 >                        data->AnimationFromState = *(uint16_t *)(Active_Player + 0x1AFE);
417 >                        data->AnimationType = *(uint16_t *)(Active_Player + 0x1B00);
418 >                        data->NextAnimationType = *(uint16_t *)(Active_Player + 0x1B02);
419 >                        data->AnimationType2= *(uint16_t *)(Active_Player + 0x1B04);
420 >                        if(i == 0) {
421 >                                data->Inputs.Actions1 = ((GameState*)(ONgGameState))->Input.Current.Actions1;
422 >                                data->Inputs.Actions2 = ((GameState*)(ONgGameState))->Input.Current.Actions2;
423 >                        }
424 >                        else{
425 >                                data->Inputs.Actions1 = PlayerList[i]->Actions1;
426 >                                data->Inputs.Actions2 = PlayerList[i]->Actions2;
427 >                        }
428 >                        UDPServer_SendToAll(&data_out, sizeof(player_data) + FLATLINE_HEADER);
429 >                }
430 >                
431 >                if( (server_started && i !=0) || (!server_started && i != client_slot)) {
432                          Active_Input->Stop.Actions1 = ~PlayerList[i]->Actions1 & Active_Input->Current.Actions1;
433                          Active_Input->Stop.Actions2 = ~PlayerList[i]->Actions2 & Active_Input->Current.Actions2;
434                          Active_Input->Start.Actions1 = ~Active_Input->Current.Actions1 & PlayerList[i]->Actions1;
# Line 412 | Line 439 | void * ONICALL FLrInput_Update_Keys(void
439                          Active_Input->Stopped.Actions2 = ~Active_Input->Current.Actions2;
440                          Active_Input->MouseDeltaX = PlayerList[i]->MouseDeltaX;
441                          Active_Input->MouseDeltaY = PlayerList[i]->MouseDeltaY;
442 <                        UDPServer_SendToAll(&data_out, sizeof(player_data) + FLATLINE_HEADER);
416 <                        }
442 >                }
443          }
444          return ONgGameState;
445   }

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)