| 1 |
|
#include "Flatline.h" |
| 2 |
|
#include "Oni_Character.h" |
| 3 |
+ |
#include "Flatline_Client.h" |
| 4 |
|
#include "Flatline_Server.h" |
| 5 |
+ |
#include "Flatline_Events.h" |
| 6 |
|
//#include <sys/time.h> |
| 7 |
|
#include <time.h> |
| 8 |
|
uint32_t last1 = 0; uint32_t last2 = 0; |
| 457 |
|
PlayerList[i]->rare_sync_index = packet.rare_sync_data.index; |
| 458 |
|
} |
| 459 |
|
break; |
| 460 |
< |
|
| 460 |
> |
case FLATLINE_EVENT: |
| 461 |
> |
FLcEventHandler( packet.flatline_event.event_index, packet.flatline_event.intArray ); |
| 462 |
> |
break; |
| 463 |
|
default: |
| 464 |
|
DDrConsole_PrintF("Warning, recieved badly formed packet!"); |
| 465 |
|
break; |
| 505 |
|
void * ONICALL FLrInput_Update_Keys(void) |
| 506 |
|
{ |
| 507 |
|
uint16_t i; |
| 508 |
< |
/*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 |
> |
|
| 509 |
|
ActiveCharacter * Active_Player = ONgGameState->ActiveCharacters; |
| 510 |
|
Active_Player->PhyContext->Rotation; |
| 511 |
|
Active_Player->PhyContext->Position; |
| 512 |
|
ONgGameState->PlayerCharacter->Position; |
| 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 0 |
| 528 |
– |
//else if sprint timer is equal to -1, display -1 |
| 529 |
– |
//else display difference |
| 530 |
– |
//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_INPUT |
| 514 |
|
if(client_connected) |
| 515 |
|
{ |
| 516 |
|
int sent_bytes; |
| 526 |
|
|
| 527 |
|
//return ONgGameState; |
| 528 |
|
} |
| 529 |
< |
#endif |
| 530 |
< |
//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 |
> |
|
| 531 |
|
if(!(server_started || client_connected)) return ONgGameState; |
| 532 |
|
|
| 533 |
|
for(i = 0; i < max_connections; i++) { |
| 536 |
|
GameInput * Active_Input; |
| 537 |
|
if(PlayerList[i] == 0) continue; |
| 538 |
|
|
| 539 |
< |
//is this right? |
| 539 |
> |
|
| 540 |
|
Player = PlayerList[i]->Chr; |
| 541 |
< |
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); |
| 582 |
|
|
| 583 |
|
if(Active_Player == 0) continue; |
| 584 |
|
Active_Input = &(Active_Player->Input); |
| 586 |
|
player_data * data; |
| 587 |
|
flatline_packet data_out = {0}; |
| 588 |
|
|
| 589 |
< |
//if( PlayerList[i]->Chr->Health == 0) PlayerList[i]->Chr->Health = PlayerList[i]->Chr->MaxHealth; |
| 589 |
> |
|
| 590 |
|
|
| 591 |
|
data_out.id = PLAYER_DATA; |
| 592 |
|
data = (void*)&(data_out.data); |
| 602 |
|
|
| 603 |
|
if(Active_Player->targetThrow) |
| 604 |
|
{ |
| 605 |
< |
data->throw_data.throwing = Active_Player->throwing; |
| 605 |
> |
data->throw_data.throwing = Players[Active_Player->throwing].list_slot; |
| 606 |
|
memcpy(data->throw_data.throwName, TMrInstance_GetInstanceName(Active_Player->targetThrow), 31); |
| 607 |
|
data->throw_data.throwFrame = ONrGetActiveCharacter(Active_Player->targetThrow)->Frame; |
| 597 |
– |
|
| 608 |
|
} |
| 609 |
|
|
| 600 |
– |
|
| 601 |
– |
|
| 610 |
|
|
| 611 |
|
if( PlayerList[i]->OldClass != PlayerList[i]->Chr->ONCC || memcmp( &(PlayerList[i]->Inventory), &(PlayerList[i]->Chr->Inventory), sizeof(Inventory) ) ) |
| 612 |
|
{ |
| 638 |
|
|
| 639 |
|
if( (server_started && i !=0) || (!server_started/* && i != client_slot*/) ) |
| 640 |
|
{ |
| 633 |
– |
//this just made sync even worse... |
| 634 |
– |
#ifdef JITTER_FIX |
| 635 |
– |
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 |
– |
#else |
| 649 |
– |
|
| 641 |
|
Active_Input->Stop.Actions1 = ~PlayerList[i]->Actions1 & Active_Input->Current.Actions1; |
| 642 |
|
Active_Input->Stop.Actions2 = ~PlayerList[i]->Actions2 & Active_Input->Current.Actions2; |
| 643 |
|
Active_Input->Start.Actions1 = ~Active_Input->Current.Actions1 & PlayerList[i]->Actions1; |
| 649 |
|
Active_Input->Stopped.Actions2 = ~Active_Input->Current.Actions2; |
| 650 |
|
Active_Input->MouseDeltaX = PlayerList[i]->MouseDeltaX; |
| 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); |
| 652 |
|
|
| 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 |
| 653 |
|
|
| 677 |
– |
#ifdef BETTER_SYNC |
| 654 |
|
if( !server_started && PlayerList[i]->player_data.Health != 0) { |
| 655 |
|
void* OldAnimation; |
| 656 |
|
void* Animation; |
| 738 |
|
|
| 739 |
|
if (PlayerList[i]->player_data.throw_data.throwName[0] != 0) |
| 740 |
|
{ |
| 741 |
< |
if ((pd->throw_data.throwing != 0xFFFF) && |
| 742 |
< |
(pd->throw_data.throwing != Active_Player->throwing) && |
| 741 |
> |
pd->throw_data.throwing = PlayerList[pd->throw_data.throwing]->spawnnumber; |
| 742 |
> |
if ((pd->throw_data.throwing != Active_Player->throwing) && |
| 743 |
|
(pd->throw_data.throwFrame < 10)) |
| 744 |
|
{ |
| 745 |
|
void *throw_animation; |
| 776 |
|
} |
| 777 |
|
|
| 778 |
|
} |
| 803 |
– |
#endif |
| 804 |
– |
|
| 779 |
|
} |
| 780 |
|
} |
| 781 |
|
|
| 782 |
|
return ONgGameState; |
| 783 |
< |
} |
| 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 |
> |
} |