Changeset 583
- Timestamp:
- Jan 22, 2011, 5:28:52 PM (14 years ago)
- Location:
- Daodan/MSVC
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
Daodan/MSVC/Flatline.c
r582 r583 47 47 } 48 48 49 enum 50 { 51 JustSpawned, 52 FirstPass, 53 SecondPass, 54 NoPass, 55 }; 56 49 57 bool FLrServer_PacketCallback(char* data, int datalen, int from) 50 58 { … … 159 167 case CHANGE_NAME: 160 168 ; //wtf, needed or i get an error. 161 DDrConsole_PrintF("Changing Name to: %s", packet->data);169 // DDrConsole_PrintF("Changing Name to: %s", packet->data); 162 170 for(i = 0; i < MAX_PLAYERS; i++) { 163 if(Player s[i].ip == sender.sin_addr.S_un.S_addr) {171 if(PlayerList[i] && PlayerList[i]->ip == sender.sin_addr.S_un.S_addr) { 164 172 found_player = 1; 165 173 break; 166 174 } 167 175 } 168 if(found_player == 0) return true;176 if(found_player == 0) break; 169 177 else { 170 178 bool name_exists = 0; 171 179 for(j = 0; j < MAX_PLAYERS; j++) { 172 if( !strcmp(packet->data, Players[j].name)) {180 if(PlayerList[j] && !strcmp(packet->data, PlayerList[j]->name)) { 173 181 name_exists = 1; 174 182 break; … … 176 184 } 177 185 if(!name_exists) { 178 char message_buffer[1024]; 179 sprintf(message_buffer,"%s changed their name to %s", Players[i].name, packet->data); 180 COrMessage_Print(message_buffer, "name_change", 0); 181 memcpy(Players[i].name, packet->data, 256); 182 186 FLsUpdateName( i, packet->data ); 183 187 } 184 188 break; … … 193 197 } 194 198 195 if(found_player == 0) return true;199 if(found_player == 0) break; 196 200 else { 197 201 input_struct * packet_input = &packet->input_struct; … … 217 221 } 218 222 219 if(found_player == 0) return true;223 if(found_player == 0) break; 220 224 if(packet->ping != lastPingTime) 221 225 { … … 301 305 case MESSAGE: 302 306 COrMessage_Print(packet.data, "chat", 0); 307 break; 308 case CHANGE_NAME: 309 if(PlayerList[(char)packet.data[0]]) 310 { 311 char message_buffer[1024]; 312 sprintf(message_buffer,"%s changed their name to %s", PlayerList[(char)packet.data[0]]->name, packet.data + 1); 313 COrMessage_Print(message_buffer, "name_change", 0); 314 315 sprintf_s(PlayerList[packet.data[0]]->name, 32, "%s", packet.data + 1); 316 317 } 303 318 break; 304 319 case CONNECT_SEND: … … 331 346 Players[chr_index].spawnnumber = chr_index; 332 347 DDrConsole_PrintF("Spawning player %s, class %s, slot %i", ((new_player*)(packet.data))->Character.OSD.Name, ((new_player*)(packet.data))->Character.OSD.Class,chr_index) ; 348 sprintf_s(Players[chr_index].name, 32, "%s", ((new_player*)(packet.data))->Character.OSD.Name); 333 349 } 334 350 //Players[((new_player*)(packet.data))->Playernumber].spawnnumber = ONrGameState_NewCharacter(&(((new_player*)(packet.data))->Character), NULL, NULL, 0); … … 347 363 348 364 memcpy( &(PlayerList[i]->player_data), pd, sizeof(player_data) ); 349 365 if(PlayerList[i]->player_data.Health == 0) 366 { 367 short breakfast = 1; 368 } 350 369 if( !server_started && pd->rare_sync_index > PlayerList[i]->rare_sync_index ) 351 370 { … … 358 377 } 359 378 360 PlayerList[i]->DataApplied = 0;379 PlayerList[i]->DataApplied = NoPass; 361 380 362 381 … … 419 438 PlayerList[Player]->DesiredFacing = packet.all_input[Player].DesiredFacing; 420 439 PlayerList[Player]->Position = packet.all_input[Player].Position; 440 PlayerList[Player]->NeedToSetFP = 1; 421 441 } 422 442 } … … 462 482 463 483 DDrConsole_PrintColored("Connection successful!",0,green, grey); 484 485 sprintf_s( PlayerList[client_slot]->name, 32, "%s", player_name ); 464 486 465 487 //disable local input. … … 528 550 } IMtPoint2D; 529 551 static flatline_packet cache_input = {0}; 530 enum 531 { 532 FirstPass, 533 SecondPass, 534 NoPass, 535 }; 552 536 553 bool ShouldSendUpdate( int i, Character* Player, ActiveCharacter* Active_Player ) 537 554 { … … 545 562 void * ONICALL FLrInput_Update_Keys(void) 546 563 { 547 uint 16_t i;564 uint32_t i; 548 565 flatline_packet all_input = {0}; 549 566 int16_t InputIndex = 0; 550 //ActiveCharacter * Active_Player = ONgGameState->ActiveCharacters;551 567 552 568 if(client_connected) … … 559 575 input_packet.id = PLAYER_INPUT; 560 576 input_packet.input_struct.Time = ONgGameState->GameTime; 561 // ((GameState*)(ONgGameState))->Input.Current.Actions1 |= Action_Backward | Action_StepLeft;562 577 input_packet.input_struct.Actions1 = ((GameState*)(ONgGameState))->Input.Current.Actions1; 563 578 input_packet.input_struct.Actions2 = ((GameState*)(ONgGameState))->Input.Current.Actions2; … … 593 608 GameInput * Active_Input; 594 609 if(PlayerList[i] == 0) continue; 610 595 611 Player = PlayerList[i]->Chr; 596 if(server_started) 612 Active_Player = ONrGetActiveCharacter( PlayerList[i]->Chr); 613 614 if(!Player) 615 { 616 DDrConsole_Print("Warning, missing Character!"); 617 continue; 618 } 619 if(server_started && PlayerList[i]->Chr->Health > 0 ) 597 620 { 598 621 … … 609 632 //Infinity... 610 633 *(int *)&all_input.all_input[InputIndex].Position.X = 0x7f800000; 634 if(Active_Player) 635 { 636 all_input.all_input[InputIndex].Position = Active_Player->PhyContext->Position; 637 } 638 611 639 612 640 all_input.all_input[InputIndex].PlayerNum = i; … … 614 642 } 615 643 616 if( Player->Health == 0) 644 645 //Set the health properly first. 646 if( client_connected && PlayerList[i]->DataApplied == FirstPass ) 617 647 { 618 int Actions; 648 ONrCharacter_SetHitPoints( PlayerList[i]->Chr, PlayerList[i]->player_data.Health); 649 } 650 //If the player is dead 651 if( PlayerList[i]->Chr->Health == 0 ) 652 653 { 619 654 const short TicksToRespawn = 3 * 60; 655 656 //Permanently kill off dumb AI 657 if(PlayerList[i]->flags & PF_SCRIPTEDAI) 658 { 659 FLrPlayerDisconnect( i ); 660 continue; 661 } 662 663 //Just to know if we have started counting off the respawn 620 664 if(PlayerList[i]->state != STATE_DEAD) 621 665 { … … 626 670 ONrGameState_Timer_Start( "", TicksToRespawn ); 627 671 } 628 } 629 630 if(server_started && i == 0) 672 673 if(server_started) 674 { 675 FLsPublic_Event( EV_KILLED, &i ); 676 } 677 678 } 679 680 //Server respawning 681 if(server_started) 631 682 { 632 Actions = ONgGameState->Input.Current.Actions1; 633 } 634 else 635 { 636 Actions = PlayerList[i]->Actions1; 637 } 638 639 if(PlayerList[i]->flags & PF_SCRIPTEDAI) 640 { 641 FLrPlayerDisconnect( i ); 642 } 643 else if(ONgGameState->GameTime - PlayerList[i]->DeathTime < TicksToRespawn ) 683 int Actions; 684 if(i == 0) 685 { 686 Actions = ONgGameState->Input.Current.Actions1; 687 } 688 else 689 { 690 Actions = PlayerList[i]->Actions1; 691 } 692 693 if(ONgGameState->GameTime - PlayerList[i]->DeathTime > TicksToRespawn && 694 (Actions & (Action_Punch | Action_Kick)) ) 695 { 696 FLrPlayerRespawn( i ); 697 698 FLsPublic_Event( EV_RESPAWN, &i ); 699 } 700 else 701 { 702 continue; 703 } 704 } 705 else //clients?! 644 706 { 645 707 continue; 646 708 } 647 else if(Actions & (Action_Punch | Action_Kick)) 648 { 649 FLrPlayerRespawn( i ); 650 } 651 continue; 652 653 654 } 655 656 Active_Player = ONrGetActiveCharacter( PlayerList[i]->Chr); 709 } 710 711 PlayerList[i]->state = STATE_ALIVE; 712 713 657 714 658 715 if(Active_Player == 0) continue; … … 662 719 //Active_Player->PlayingFilm.Flags = 1; 663 720 Active_Input = &(Active_Player->Input); 664 if(server_started) 665 { 666 all_input.all_input[InputIndex - 1].Position = Active_Player->PhyContext->Position; 667 } 721 668 722 if(server_started && 669 723 ShouldSendUpdate( i, PlayerList[i]->Chr, Active_Player) ) … … 728 782 729 783 730 if( !server_started && PlayerList[i]->player_data.Health != 0 ) {784 if( !server_started && PlayerList[i]->player_data.Health != 0 && PlayerList[i]->Chr->Health != 0) { 731 785 void* OldAnimation; 732 786 void* Animation; 733 787 player_data* pd = &PlayerList[i]->player_data; 734 788 735 PlayerList[i]->Chr->Facing = PlayerList[i]->Facing; 736 PlayerList[i]->Chr->DesiredFacing = PlayerList[i]->DesiredFacing; 789 //This is getting crazy. WTB new packet system 790 if(PlayerList[i]->NeedToSetFP) 791 { 792 PlayerList[i]->Chr->Facing = PlayerList[i]->Facing; 793 PlayerList[i]->Chr->DesiredFacing = PlayerList[i]->DesiredFacing; 737 794 738 if(*(int*)&PlayerList[i]->Chr->Position.X != 0x7f800000) 739 { 740 Active_Player->PhyContext->Position = PlayerList[i]->Position; 741 } 742 else 743 { 744 int breakfast = 0; 745 } 746 /* 747 if(isnan(Active_Player->PhyContext->Position.Y) || 748 isnan(Active_Player->PhyContext->Position.X) || 749 isnan(Active_Player->PhyContext->Position.Z) ) 750 { 751 //DDrConsole_PrintF("Player is NAN! %x %x", Active_Player->PhyContext->Position.Y, PlayerList[i]->Height); 752 DDrConsole_PrintF("Player is NAN! %x %x %x", Active_Player->PhyContext->Position.X, Active_Player->PhyContext->Position.Y, Active_Player->PhyContext->Position.Z); 753 //DDrConsole_PrintF("Velocity %x %x %x", Active_Player->PhyContext->Velocity.X, Active_Player->PhyContext->Velocity.Y, Active_Player->PhyContext->Velocity.Z); 754 755 756 } 757 */ 795 if(*(int*)&PlayerList[i]->Chr->Position.X != 0x7f800000) 796 { 797 Active_Player->PhyContext->Position = Player->Location = PlayerList[i]->Position; 798 799 } 800 PlayerList[i]->NeedToSetFP = 0; 801 } 758 802 759 803 if( PlayerList[i]->DataApplied == FirstPass ) … … 761 805 PlayerList[i]->DataApplied = SecondPass; 762 806 763 Player->Health = PlayerList[i]->player_data.Health;807 //Player->Health = PlayerList[i]->player_data.Health; 764 808 PlayerList[i]->Chr->MaxHealth = PlayerList[i]->player_data.MaxHealth; 765 809 … … 844 888 if (PlayerList[i]->player_data.throw_data.throwName[0] != 0) 845 889 { 846 short throwTarget = PlayerList[pd->throw_data.throwing]->spawnnumber; 847 if ((throwTarget != Active_Player->throwing) && 848 (pd->throw_data.throwFrame < 10)) 890 if(PlayerList[pd->throw_data.throwing]) 849 891 { 850 void *throw_animation; 851 ActiveCharacter* Target; 852 // get the animation 853 854 TMrInstance_GetDataPtr( 855 'TRAM', 856 pd->throw_data.throwName, 857 &throw_animation); 858 //if (error) return; 859 860 // set the throw target 861 Active_Player->ThrowTargetCharacter = &ONgGameState->CharacterStorage[throwTarget]; 862 Target = ONrGetActiveCharacter(Active_Player->ThrowTargetCharacter); 863 if ((Target->Animation != throw_animation) && 864 (OldAnimation != Animation) && 865 !(Active_Player->ThrowTargetCharacter->Flags & ONcCharacterFlag_BeingThrown)) 892 short throwTarget = PlayerList[pd->throw_data.throwing]->spawnnumber; 893 if ((throwTarget != Active_Player->throwing) && 894 (pd->throw_data.throwFrame < 10)) 866 895 { 867 // set the throw variables 868 Active_Player->targetThrow = throw_animation; 869 Active_Player->throwing = throwTarget; 870 871 // run the throw 872 ONrCharacter_NewAnimationHook(Player, Active_Player); 873 874 if (Active_Player->ThrowTargetCharacter) 896 void *throw_animation; 897 ActiveCharacter* Target; 898 // get the animation 899 900 TMrInstance_GetDataPtr( 901 'TRAM', 902 pd->throw_data.throwName, 903 &throw_animation); 904 //if (error) return; 905 906 // set the throw target 907 Active_Player->ThrowTargetCharacter = &ONgGameState->CharacterStorage[throwTarget]; 908 Target = ONrGetActiveCharacter(Active_Player->ThrowTargetCharacter); 909 if ((Target->Animation != throw_animation) && 910 (OldAnimation != Animation) && 911 !(Active_Player->ThrowTargetCharacter->Flags & ONcCharacterFlag_BeingThrown)) 875 912 { 876 Target->Frame += 2; 877 Target->thrownBy = Player->Number; 913 // set the throw variables 914 Active_Player->targetThrow = throw_animation; 915 Active_Player->throwing = throwTarget; 916 917 // run the throw 918 ONrCharacter_NewAnimationHook(Player, Active_Player); 919 920 if (Active_Player->ThrowTargetCharacter) 921 { 922 Target->Frame += 2; 923 Target->thrownBy = Player->Number; 924 } 878 925 } 879 926 } 927 } 928 else 929 { 930 DDrConsole_PrintF("Warning, tried to throw nonexistant player %hi", pd->throw_data.throwing ); 880 931 } 881 932 } //throw check … … 885 936 886 937 //Check for character switching requests 887 if(server_started && PlayerList[i]-> Actions1 & Action_Block && PlayerList[i]->ShapeshiftCooldown < ONgGameState->GameTime)938 if(server_started && PlayerList[i]->player_data.Health != 0 && PlayerList[i]->Chr->Health != 0 && PlayerList[i]->Actions1 & Action_Block && PlayerList[i]->ShapeshiftCooldown < ONgGameState->GameTime) 888 939 { 889 940 int error; … … 1002 1053 TSrContext_SetShade(ScoreboardInstance, green); 1003 1054 } 1004 TSrContext_DrawText(ScoreboardInstance, PlayerList[i]-> Chr->Name, 255, 0, &DrawLocation);1055 TSrContext_DrawText(ScoreboardInstance, PlayerList[i]->name, 255, 0, &DrawLocation); 1005 1056 TSrContext_SetShade(ScoreboardInstance, white); 1006 1057 DrawLocation.x += 150; -
Daodan/MSVC/Flatline.h
r582 r583 164 164 //used for storing data about each player 165 165 typedef struct { 166 int FLATLINE;167 charid;166 //int FLATLINE; 167 int id; 168 168 int packet_index; 169 169 union … … 180 180 flatline_event flatline_event; 181 181 uint32_t ping; 182 player_input all_input[3 2];182 player_input all_input[33]; 183 183 }; 184 184 } flatline_packet; … … 213 213 enum FlatlineEvent { 214 214 EV_RESPAWN, 215 EV_KILLED, 215 216 EV_DISCONNECT, 216 217 EV_DOOR_OPEN, … … 269 270 uint32_t Ping; 270 271 bool DataApplied; 271 272 bool NeedToSetFP; 272 273 uint32_t ShapeshiftCooldown; 273 274 } player_info; -
Daodan/MSVC/Flatline_BSL.c
r582 r583 43 43 if(server_started) 44 44 { 45 sprintf_s(PlayerList[0]->Chr->Name,32, args[0].value_str32);45 FLsUpdateName( 0, args[0].value_str32 ); 46 46 } 47 47 return 0; … … 129 129 uint16_t ONICALL kick(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret) 130 130 { 131 if(server_started && PlayerList[args[0].value_int32]) 132 { 133 ONrCharacter_SetHitPoints(PlayerList[args[0].value_int32]->Chr, 0); 131 134 FLrPlayerDisconnect(args[0].value_int32); 132 135 FLsPublic_Event(EV_DISCONNECT, &args[0].value_int32); 136 } 133 137 return 0; 134 138 } … … 180 184 PlayerList[playerlist_slot]->spawnnumber = player_slot; 181 185 PlayerList[playerlist_slot]->Chr = &((Character *)(((GameState * )(ONgGameState))->CharacterStorage))[player_slot]; 186 sprintf_s(PlayerList[playerlist_slot]->name, 32, "%s", PlayerList[playerlist_slot]->Chr->Name); 182 187 // PlayerList[playerlist_slot]->Chr->Flags = chr_dontaim | chr_unkillable; //&= 0xFFBFFFFF; //WTF 183 188 // if(!is_bot) PlayerList[playerlist_slot]->Chr->Flags &= 0xFFBFFFFF; //WTF -
Daodan/MSVC/Flatline_Server.c
r582 r583 78 78 //PlayerList[playerlist_slot]->Chr->Flags = chr_dontaim | chr_unkillable; //&= 0xFFBFFFFF; //WTF 79 79 if(!is_bot) PlayerList[playerlist_slot]->Chr->Flags &= 0xFFBFFFFF; //WTF, magic number. 80 sprintf(PlayerList[playerlist_slot]->Chr->Name, "%.31s", name); 80 sprintf_s(PlayerList[playerlist_slot]->Chr->Name, 32, "%s", name); 81 sprintf_s(PlayerList[playerlist_slot]->name, 32, "%s", name); 81 82 UDPServer_SendToAll( (char*)&new_char, sizeof(new_player) + FLATLINE_HEADER ); 82 83 … … 91 92 PlayerList[playerlist_slot]->ip = ip; 92 93 PlayerList[playerlist_slot]->list_slot = playerlist_slot; 93 sprintf (PlayerList[playerlist_slot]->name,"%.31s",name);94 sprintf_s(PlayerList[playerlist_slot]->name, 32, "%s", name); 94 95 95 96 MultiplayerStatus.PleaseUpdateAllPlayers = 1; … … 152 153 UDPServer_SendToAll(&ping, FLATLINE_HEADER + 4); 153 154 } 155 156 void FLsUpdateName( int index, char* name ) 157 { 158 flatline_packet message; 159 int message_size; 160 161 char message_buffer[1024]; 162 sprintf(message_buffer,"%s changed their name to %s", PlayerList[index]->name, name); 163 COrMessage_Print(message_buffer, "name_change", 0); 164 165 sprintf_s(PlayerList[index]->name, 32, "%s", name); 166 sprintf_s(PlayerList[index]->Chr->Name, 32, "%s", name); 167 168 message.id = CHANGE_NAME; 169 message.data[0] = index; 170 message_size = sprintf(message.data + 1, "%s", name); 171 172 UDPServer_SendToAll(&message, message_size + 2 + FLATLINE_HEADER); 173 } -
Daodan/MSVC/Flatline_Server.h
r580 r583 13 13 void FLrServer_Initialize(); 14 14 void FLsPingAll(); 15 void FLsUpdateName( int index, char* name ); 15 16 #endif
Note:
See TracChangeset
for help on using the changeset viewer.