Changeset 579
- Timestamp:
- Jan 13, 2011, 2:02:52 AM (14 years ago)
- Location:
- Daodan/MSVC
- Files:
-
- 2 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
Daodan/MSVC/Daodan_Utility.c
r578 r579 176 176 } 177 177 178 void* ScoreboardInstance = 0;179 void FLrRun_Scores()180 {181 182 if(!ScoreboardInstance){183 void* TSFFTahoma;184 TMrInstance_GetDataPtr( 'TSFF', "Tahoma", &TSFFTahoma);185 TSrContext_New( TSFFTahoma, 7, 1, 1, 0, &ScoreboardInstance);186 }187 if(ScoreboardInstance){188 int white = 0x00FFFFFF;189 IMtPoint2D DrawLocation = {20, 20};190 TSrContext_SetShade(ScoreboardInstance, white);191 TSrContext_DrawText(ScoreboardInstance, "Scores and crap", 255, 0, &DrawLocation);192 }193 }194 195 178 void ONICALL DDrText_Hook() 196 179 { -
Daodan/MSVC/Flatline.c
r578 r579 1 1 #include "Flatline.h" 2 2 #include "Oni_Character.h" 3 #include "Flatline_Client.h" 3 4 #include "Flatline_Server.h" 5 #include "Flatline_Events.h" 4 6 //#include <sys/time.h> 5 7 #include <time.h> … … 456 458 } 457 459 break; 458 460 case FLATLINE_EVENT: 461 FLcEventHandler( packet.flatline_event.event_index, packet.flatline_event.intArray ); 462 break; 459 463 default: 460 464 DDrConsole_PrintF("Warning, recieved badly formed packet!"); … … 502 506 { 503 507 uint16_t i; 504 /*DDrConsole_PrintF("Current: %x %x | Start: %x %x | Stop: %x %x | Stopped %x %x", 505 ONgGameState->Input.Current.Actions1, ONgGameState->Input.Current.Actions2, 506 ONgGameState->Input.Start.Actions1,ONgGameState->Input.Start.Actions2, 507 ONgGameState->Input.Stop.Actions1, ONgGameState->Input.Stop.Actions2, 508 ONgGameState->Input.Stopped.Actions2, ONgGameState->Input.Stopped.Actions2 509 ); 510 */ 508 511 509 ActiveCharacter * Active_Player = ONgGameState->ActiveCharacters; 512 510 Active_Player->PhyContext->Rotation; … … 514 512 ONgGameState->PlayerCharacter->Position; 515 513 516 517 518 /*519 if( ONgGameState->Input.MouseDeltaX != 0 || ONgGameState->Input.MouseDeltaY != 0 ||520 ONgGameState->Input.field_8 != 0 || ONgGameState->Input.field_C != 0 )521 522 DDrConsole_PrintF("%f %f | %f %f",523 ONgGameState->Input.MouseDeltaX , ONgGameState->Input.MouseDeltaY,524 ONgGameState->Input.field_8, ONgGameState->Input.field_C);525 526 */527 //if sprint timer is equal to 0, display 0528 //else if sprint timer is equal to -1, display -1529 //else display difference530 //good thing this is just quick an dirty debug stuff :)531 532 //basically it seems that if the difference is bigger than 15 frames, you cant dash. : /533 534 #ifndef SPAM_INPUT535 514 if(client_connected) 536 515 { … … 548 527 //return ONgGameState; 549 528 } 550 #endif 551 //Testing drawing text to the screen...this failed. Will need to get it working eventually. 552 if( TSrTest ) 553 { 554 // OniRectangle TextRect = { 128, 128, 256, 256 }; 555 IMtPoint2D Point = {50, 50}; 556 //TSrContext_DrawText(TSrTest, "Testing woohoo", 255, 0, &Point); 557 TSrContext_DrawText(TSrTest, "WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW", 255, 0, &Point); 558 559 } 529 530 560 531 if(!(server_started || client_connected)) return ONgGameState; 561 532 … … 566 537 if(PlayerList[i] == 0) continue; 567 538 568 //is this right?539 569 540 Player = PlayerList[i]->Chr; 570 Active_Player = (void*)ONrGetActiveCharacter( PlayerList[i]->Chr); 541 if( Player->Health == 0) 542 { 543 int Actions; 544 const short TicksToRespawn = 3 * 60; 545 if(PlayerList[i]->state != STATE_DEAD) 546 { 547 PlayerList[i]->state = STATE_DEAD; 548 PlayerList[i]->DeathTime = ONgGameState->GameTime; 549 if(i == client_slot) 550 { 551 ONrGameState_Timer_Start( "", TicksToRespawn ); 552 } 553 } 554 555 if(server_started & i == 0) 556 { 557 Actions = ONgGameState->Input.Current.Actions1; 558 } 559 else 560 { 561 Actions = PlayerList[i]->Actions1; 562 } 563 564 if(PlayerList[i]->flags & PF_SCRIPTEDAI) 565 { 566 FLrPlayerDisconnect( i ); 567 } 568 else if(ONgGameState->GameTime - PlayerList[i]->DeathTime < TicksToRespawn ) 569 { 570 continue; 571 } 572 else if(Actions & (Action_Punch | Action_Kick)) 573 { 574 FLrPlayerRespawn( i ); 575 } 576 continue; 577 578 579 } 580 581 Active_Player = ONrGetActiveCharacter( PlayerList[i]->Chr); 571 582 572 583 if(Active_Player == 0) continue; … … 576 587 flatline_packet data_out = {0}; 577 588 578 //if( PlayerList[i]->Chr->Health == 0) PlayerList[i]->Chr->Health = PlayerList[i]->Chr->MaxHealth;589 579 590 580 591 data_out.id = PLAYER_DATA; … … 592 603 if(Active_Player->targetThrow) 593 604 { 594 data->throw_data.throwing = Active_Player->throwing;605 data->throw_data.throwing = Players[Active_Player->throwing].list_slot; 595 606 memcpy(data->throw_data.throwName, TMrInstance_GetInstanceName(Active_Player->targetThrow), 31); 596 607 data->throw_data.throwFrame = ONrGetActiveCharacter(Active_Player->targetThrow)->Frame; 597 598 } 599 600 608 } 601 609 602 610 … … 631 639 if( (server_started && i !=0) || (!server_started/* && i != client_slot*/) ) 632 640 { 633 //this just made sync even worse...634 #ifdef JITTER_FIX635 input_struct * New_Input = &PlayerList[i]->MouseDeltaX;636 input_struct * Cache_Input = &PlayerList[i]->CacheInput;637 Active_Input->Stop.Actions1 = ~Cache_Input->Actions1 & Active_Input->Current.Actions1;638 Active_Input->Stop.Actions2 = ~Cache_Input->Actions2 & Active_Input->Current.Actions2;639 Active_Input->Start.Actions1 = ~Active_Input->Current.Actions1 & Cache_Input->Actions1;640 Active_Input->Start.Actions2 = ~Active_Input->Current.Actions2 & Cache_Input->Actions2;641 Active_Input->Current.Actions1 = Cache_Input->Actions1;642 Active_Input->Current.Actions2 = Cache_Input->Actions2;643 Active_Input->Stopped.Actions1 = ~Active_Input->Current.Actions1;644 Active_Input->Stopped.Actions2 = ~Active_Input->Current.Actions2;645 Active_Input->MouseDeltaX = Cache_Input->MouseDeltaX;646 Active_Input->MouseDeltaY = Cache_Input->MouseDeltaY;647 memcpy( Cache_Input, New_Input, sizeof(input_struct));648 #else649 650 641 Active_Input->Stop.Actions1 = ~PlayerList[i]->Actions1 & Active_Input->Current.Actions1; 651 642 Active_Input->Stop.Actions2 = ~PlayerList[i]->Actions2 & Active_Input->Current.Actions2; … … 659 650 Active_Input->MouseDeltaX = PlayerList[i]->MouseDeltaX; 660 651 Active_Input->MouseDeltaY = PlayerList[i]->MouseDeltaY; 661 //DDrConsole_PrintF("Timer: %i", (Active_Player->SprintTimer != 0) ? (Active_Player->SprintTimer == -1) ? -1 : (ONgGameState->GameTime - Active_Player->SprintTimer) : 0); 662 663 //DDrConsole_PrintF("1E8 %u", ONgGameState->PlayerCharacter->field_1E8); 664 /* 665 DDrConsole_PrintF("T %u | Current: %x %x | Start: %x %x | Stop: %x %x | Stopped %x %x", 666 PlayerList[i]->LastInputTime, 667 Active_Input->Current.Actions1, Active_Input->Current.Actions2, 668 Active_Input->Start.Actions1,Active_Input->Start.Actions2, 669 Active_Input->Stop.Actions1, Active_Input->Stop.Actions2, 670 Active_Input->Stopped.Actions1, Active_Input->Stopped.Actions2 671 ); 672 */ 673 674 675 #endif 676 677 #ifdef BETTER_SYNC 652 653 678 654 if( !server_started && PlayerList[i]->player_data.Health != 0) { 679 655 void* OldAnimation; … … 763 739 if (PlayerList[i]->player_data.throw_data.throwName[0] != 0) 764 740 { 765 if ((pd->throw_data.throwing != 0xFFFF) &&766 741 pd->throw_data.throwing = PlayerList[pd->throw_data.throwing]->spawnnumber; 742 if ((pd->throw_data.throwing != Active_Player->throwing) && 767 743 (pd->throw_data.throwFrame < 10)) 768 744 { … … 801 777 802 778 } 803 #endif804 805 779 } 806 780 } … … 808 782 return ONgGameState; 809 783 } 784 785 void FLrPlayerDisconnect( int Player ) 786 { 787 if(server_started) 788 { 789 //FLsPublic_Event(EV_DISCONNECT, &Player ); 790 } 791 //Kill off the character in another function, please 792 //ONrCharacter_SetHitPoints( PlayerList[Player]->Chr, 0); 793 794 memset(PlayerList[Player], 0, sizeof(player_info)); 795 PlayerList[Player] = 0; 796 797 798 799 return; 800 } 801 802 void FLrPlayerRespawn( int Player ) 803 { 804 PlayerList[Player]->state = STATE_ALIVE; 805 ONrCorpse_Create(PlayerList[Player]->Chr); 806 ONrCharacter_SetHitPoints( PlayerList[Player]->Chr, PlayerList[Player]->Chr->MaxHealth ); 807 } 808 809 810 void* ScoreboardInstance = 0; 811 void FLrRun_Scores() 812 { 813 if(client_connected || server_started) 814 { 815 if(!ScoreboardInstance){ 816 void* TSFFTahoma; 817 TMrInstance_GetDataPtr( 'TSFF', "Tahoma", &TSFFTahoma); 818 TSrContext_New( TSFFTahoma, 7, 1, 1, 0, &ScoreboardInstance); 819 } 820 if(ScoreboardInstance){ 821 const int white = 0x00FFFFFF; 822 const int green = 0x0000FF00; 823 const int red = 0x00FF0000; 824 int i; 825 char DrawString[255]; 826 const int LineHeight = 15; 827 IMtPoint2D DrawLocation = {20, 20}; 828 TSrContext_SetShade(ScoreboardInstance, white); 829 TSrContext_DrawText(ScoreboardInstance, "Oni Flatline build " __DATE__ " " __TIME__, 255, 0, &DrawLocation); 830 DrawLocation.y += LineHeight; 831 TSrContext_DrawText(ScoreboardInstance, "Name", 255, 0, &DrawLocation); 832 DrawLocation.x += 150; 833 TSrContext_DrawText(ScoreboardInstance, "Score", 255, 0, &DrawLocation); 834 for(i = 0; i <MAX_PLAYERS; i++) 835 { 836 if(PlayerList[i] == 0) continue; 837 838 DrawLocation.x = 20; 839 DrawLocation.y += LineHeight; 840 841 if(PlayerList[i]->Chr->Health == 0) 842 { 843 TSrContext_SetShade(ScoreboardInstance, red); 844 } 845 else if (i == client_slot) 846 { 847 TSrContext_SetShade(ScoreboardInstance, green); 848 } 849 TSrContext_DrawText(ScoreboardInstance, PlayerList[i]->Chr->Name, 255, 0, &DrawLocation); 850 TSrContext_SetShade(ScoreboardInstance, white); 851 DrawLocation.x += 150; 852 sprintf(DrawString, "%i", PlayerList[i]->Chr->Damage); 853 TSrContext_DrawText(ScoreboardInstance, DrawString, 255, 0, &DrawLocation); 854 855 } 856 } 857 } 858 } -
Daodan/MSVC/Flatline.h
r578 r579 174 174 175 175 enum { 176 NULL_PACKET, // 176 NULL_PACKET, //Don't use. ;) 177 177 CONNECT_SEND, 178 178 CONNECT_REPLY, … … 227 227 uint16_t state; 228 228 int flags; 229 int DeathTime; 229 230 } player_info; 230 231 … … 250 251 extern char player_name[]; 251 252 void FLrRun_Scores(); 252 void PlayerDisconnect( int Player ); 253 void FLrPlayerDisconnect( int Player ); 254 void FLrPlayerRespawn( int Player ); 253 255 int FLrEvent_GetNumArgs( int eventIndex ); 254 256 #endif -
Daodan/MSVC/Flatline_BSL.c
r578 r579 128 128 uint16_t ONICALL kick(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret) 129 129 { 130 PlayerDisconnect(args[0].value_int32); 130 FLrPlayerDisconnect(args[0].value_int32 - 1); 131 FLsPublic_Event(EV_DISCONNECT, &args[0].value_int32); 131 132 return 0; 132 133 } -
Daodan/MSVC/Flatline_Server.c
r578 r579 124 124 } 125 125 126 //FLsPublic_Event 126 127 //Sends an event (door opening, player disconnecting, etc) to all players 127 128 //Always make sure you send a pointer to this, even if it is just one arg. ;) 128 void FLsPublic_Event( unsigned int eventIndex, int * args ) 129 //Returns 0 because mixing C and assembly is stupid. 130 //If it is void the double door in State crashes. Probably stack corruption, 131 //I'm not sure exactly why. 132 int FLsPublic_Event( const unsigned int eventIndex, const int * args ) 129 133 { 130 134 int numArgs = FLrEvent_GetNumArgs( eventIndex ); 135 int ret; 131 136 flatline_packet eventPacket = {0}; 132 137 eventPacket.id = FLATLINE_EVENT; 133 138 eventPacket.flatline_event.event_index = eventIndex; 134 memcpy( eventPacket.flatline_event.intArray, args, sizeof(int) * numArgs ); 135 UDPServer_SendToAll( &eventPacket, sizeof(int) * (numArgs + 1) + FLATLINE_HEADER ); 139 ret = memcpy( eventPacket.flatline_event.intArray, args, sizeof(int) * numArgs ); 140 ret = UDPServer_SendToAll( &eventPacket, sizeof(int) * (numArgs + 1) + FLATLINE_HEADER ); 141 return 0; 136 142 } 137 143 138 void PlayerDisconnect( int Player )139 {140 FLsPublic_Event(EV_DISCONNECT, &Player );141 memset(PlayerList[Player], 0, sizeof(player_info));142 return;143 } -
Daodan/MSVC/Flatline_Server.h
r573 r579 9 9 extern uint16_t max_connections; 10 10 player_info* FLrServer_AddPlayer(int ip, char* name, bool is_server, bool is_bot); 11 void FLsPublic_Event( unsigned int eventIndex,int * args);11 int FLsPublic_Event( const unsigned int eventIndex, const int * args); 12 12 13 13 void FLrServer_Initialize(); -
Daodan/MSVC/Oni_Symbols.c
r578 r579 184 184 DefFunc( OBJrConsole_OnActivate , 0x004C0880 ); 185 185 DefFunc( ONrCharacter_SetAnimationExternal , 0x004EB340 ); 186 DefFunc( ONrGameState_Timer_Start , 0x004FD370 ); 186 187 #define DefVar(type, name, address) //type* _##name = (type*)address 187 188 -
Daodan/MSVC/Oni_Symbols.h
r578 r579 124 124 void *ioTextContext, 125 125 uint32_t inShade); 126 126 typedef void (* _ONrGameState_Timer_Start)( char* function, int time ); 127 127 typedef uint16_t ( *_TRrAnimation_GetDuration)(void* Animation); 128 128 typedef uint16_t ( *_TRrAnimation_GetTo)(void* Animation); … … 170 170 ExtFunc(TRrAnimation_GetFrom); 171 171 ExtFunc(TRrAnimation_GetTo); 172 172 ExtFunc(ONrGameState_Timer_Start); 173 173 extern _UUrMachineTime_High UUrMachineTime_High; 174 174 extern _UUrMachineTime_High_Frequency UUrMachineTime_High_Frequency;
Note:
See TracChangeset
for help on using the changeset viewer.