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

Comparing Daodan/MSVC/Flatline.c (file contents):
Revision 580 by gumby, Fri Jan 14 07:39:14 2011 UTC vs.
Revision 581 by gumby, Fri Jan 14 08:36:34 2011 UTC

# Line 424 | Line 424 | bool FLrClient_Run(flatline_packet* pack
424                                                  if( !PlayerList[i] ) break;
425                                                  //PlayerList[i]->Chr = ((GameState *)ONgGameState)->CharacterStorage;
426  
427 <                                                PlayerList[i]->Actions1 = pd->Inputs.Actions1;
427 > /*                                              PlayerList[i]->Actions1 = pd->Inputs.Actions1;
428                                                  PlayerList[i]->Actions2 = pd->Inputs.Actions2;
429                                                  PlayerList[i]->MouseDeltaX = pd->Inputs.MouseDeltaX;
430 <                                                PlayerList[i]->MouseDeltaY = pd->Inputs.MouseDeltaY;
430 >                                                PlayerList[i]->MouseDeltaY = pd->Inputs.MouseDeltaY;*/
431                                                  memcpy( &(PlayerList[i]->player_data), pd, sizeof(player_data) );
432  
433                                                  if( !server_started && pd->rare_sync_index > PlayerList[i]->rare_sync_index )
# Line 483 | Line 483 | bool FLrClient_Run(flatline_packet* pack
483                                          break;
484                                  case PK_PING:
485                                          packet.id = PK_PONG;
486
486                                          NetUDPSocket_Send(client_sock, (sockaddr *) &address, (char*)&packet, FLATLINE_HEADER + 4);            
487                                          break;
488 +                                case PK_ALL_INPUT:
489 +                                        if(1)
490 +                                        {
491 +                                                int Player;
492 +                                                for(Player = 0; Player < MAX_CONNECTIONS; Player++)
493 +                                                {
494 +                                                        if(PlayerList[Player])
495 +                                                        {
496 +                                                                PlayerList[Player]->Actions1 = packet.all_input[Player].Actions1;
497 +                                                                PlayerList[Player]->Actions2 = packet.all_input[Player].Actions2;
498 +                                                                PlayerList[Player]->MouseDeltaX = packet.all_input[Player].MouseDeltaX;
499 +                                                                PlayerList[Player]->MouseDeltaY = packet.all_input[Player].MouseDeltaY;
500 +                                                        }
501 +                                                }
502 +                                        }
503 +                                        break;
504                                  default:
505                                          DDrConsole_PrintF("Warning, recieved badly formed packet!");
506                                          break;
# Line 531 | Line 546 | extern void* TSrTest;
546   void * ONICALL FLrInput_Update_Keys(void)
547   {
548          uint16_t i;
549 <
549 >        flatline_packet all_input = {0};
550          ActiveCharacter * Active_Player = ONgGameState->ActiveCharacters;
551          Active_Player->PhyContext->Rotation;
552          Active_Player->PhyContext->Position;
# Line 556 | Line 571 | void * ONICALL FLrInput_Update_Keys(void
571  
572          if(!(server_started || client_connected)) return ONgGameState;
573  
574 +        all_input.id = PK_ALL_INPUT;
575 +
576          if(server_started && ONgGameState->GameTime % 120 == 0)
577          {
578                  FLsPingAll();
# Line 568 | Line 585 | void * ONICALL FLrInput_Update_Keys(void
585                  if(PlayerList[i] == 0) continue;
586  
587  
588 +                if(i == 0) {
589 +                        all_input.all_input[i].Actions1 = ((GameState*)(ONgGameState))->Input.Current.Actions1;
590 +                        all_input.all_input[i].Actions2 = ((GameState*)(ONgGameState))->Input.Current.Actions2;
591 +                        all_input.all_input[i].MouseDeltaX = ONgGameState->Input.MouseDeltaX;
592 +                        all_input.all_input[i].MouseDeltaY = ONgGameState->Input.MouseDeltaY;
593 +                }
594 +                else{
595 +                        all_input.all_input[i].Actions1 = PlayerList[i]->Actions1;
596 +                        all_input.all_input[i].Actions2 = PlayerList[i]->Actions2;
597 +                        all_input.all_input[i].MouseDeltaX = PlayerList[i]->MouseDeltaX;
598 +                        all_input.all_input[i].MouseDeltaY = PlayerList[i]->MouseDeltaY;
599 +                }
600 +
601                  Player = PlayerList[i]->Chr;
602                  if( Player->Health == 0)
603                  {
# Line 613 | Line 643 | void * ONICALL FLrInput_Update_Keys(void
643  
644                  if(Active_Player == 0) continue;
645                  Active_Input = &(Active_Player->Input);
646 <                if(server_started) {
646 >
647 >                if(server_started && strcmp(PlayerList[i]->player_data.Animation, TMrInstance_GetInstanceName(Active_Player->Animation)))
648 >                {
649                          player_data * data;
650                          flatline_packet data_out = {0};
651  
652 <                        if(!strcmp(PlayerList[i]->player_data.Animation, TMrInstance_GetInstanceName(Active_Player->Animation)))
621 <                                continue;
622 <
652 >                        
653                          data_out.id = PLAYER_DATA;
654                          data = (void*)&(data_out.data);
655                          data->PlayerNum = i;
# Line 651 | Line 681 | void * ONICALL FLrInput_Update_Keys(void
681                          data->rare_sync_index = PlayerList[i]->rare_sync_index;
682  
683  
654                        if(i == 0) {
655                                data->Inputs.Actions1 = ((GameState*)(ONgGameState))->Input.Current.Actions1;
656                                data->Inputs.Actions2 = ((GameState*)(ONgGameState))->Input.Current.Actions2;
657                                data->Inputs.MouseDeltaX = ONgGameState->Input.MouseDeltaX;
658                                data->Inputs.MouseDeltaY = ONgGameState->Input.MouseDeltaY;
659                        }
660                        else{
661                                data->Inputs.Actions1 = PlayerList[i]->Actions1;
662                                data->Inputs.Actions2 = PlayerList[i]->Actions2;
663                                data->Inputs.MouseDeltaX = PlayerList[i]->MouseDeltaX;
664                                data->Inputs.MouseDeltaY = PlayerList[i]->MouseDeltaY;
665                        }
684                          data->Ping = PlayerList[i]->Ping;
685                          memcpy( &(PlayerList[i]->player_data), data, sizeof(player_data) );
686  
# Line 689 | Line 707 | void * ONICALL FLrInput_Update_Keys(void
707                                  void* Animation;
708                                  player_data* pd = &PlayerList[i]->player_data;
709  
692                                if(PlayerList[i]->DataApplied) continue;
710  
711 +                                //Note to self: sort out which needs to be applied the first time and which the second.
712 +                                switch(PlayerList[i]->DataApplied)
713 +                                {
714 +                                case 1:
715 +                                        PlayerList[i]->DataApplied = 2;
716 +                                        break;
717 +                                case 0:
718 +                                        PlayerList[i]->DataApplied = 1;
719 +                                case 2:
720 +                                        continue;
721 +                                }
722 +                                
723                                  Player->Health = PlayerList[i]->player_data.Health;
724                                  PlayerList[i]->Chr->MaxHealth = PlayerList[i]->player_data.MaxHealth;
725  
726                                  PlayerList[i]->Chr->Facing = PlayerList[i]->player_data.Facing;
727                                  PlayerList[i]->Chr->DesiredFacing = PlayerList[i]->player_data.DesiredFacing;
728  
729 <                                PlayerList[i]->Actions1 = PlayerList[i]->player_data.Inputs.Actions1;
729 > /*                              PlayerList[i]->Actions1 = PlayerList[i]->player_data.Inputs.Actions1;
730                                  PlayerList[i]->Actions2 = PlayerList[i]->player_data.Inputs.Actions2;
731                                  PlayerList[i]->MouseDeltaX = PlayerList[i]->player_data.Inputs.MouseDeltaX;
732 <                                PlayerList[i]->MouseDeltaY = PlayerList[i]->player_data.Inputs.MouseDeltaY;
732 >                                PlayerList[i]->MouseDeltaY = PlayerList[i]->player_data.Inputs.MouseDeltaY;*/
733                                  Active_Player->PhyContext->Position = PlayerList[i]->player_data.Position;
734                                  OldAnimation = Active_Player->Animation;
735  
# Line 756 | Line 785 | void * ONICALL FLrInput_Update_Keys(void
785                                                          ONrCharacter_NewAnimationHook(Player, Active_Player);*/
786                                                          //Player->Flags |= 0x00000010;
787                                                          ONrCharacter_SetAnimationExternal(Player, TRrAnimation_GetFrom(Animation), Animation, 0);
788 +                                                        //ONrCharacter_NewAnimationHook(Player, Active_Player);
789                                                  }
790  
791                                                  num_frames = TRrAnimation_GetDuration(Active_Player->Animation);
# Line 810 | Line 840 | void * ONICALL FLrInput_Update_Keys(void
840                                                  }
841                                          }
842                                  }
813                                PlayerList[i]->DataApplied = 1;
843  
844                          }
845                  }
846 +
847 +        }
848 +        if(server_started)
849 +        {
850 +                UDPServer_SendToAll(&all_input, FLATLINE_HEADER + sizeof(player_input) * 32);
851          }
852  
853          return ONgGameState;

Diff Legend

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