1 |
|
#include "Flatline.h" |
2 |
|
#include "Oni_Character.h" |
3 |
|
#include "Flatline_Server.h" |
4 |
+ |
#include "Flatline_Client.h" |
5 |
+ |
#include "Daodan_Utility.h" |
6 |
|
//#include <sys/time.h> |
7 |
|
#include <time.h> |
8 |
|
uint32_t last1 = 0; uint32_t last2 = 0; |
18 |
|
|
19 |
|
#define BETTER_SYNC |
20 |
|
|
21 |
+ |
void PlayerDisconnect( int Player ) |
22 |
+ |
{ |
23 |
+ |
ONrGameState_DeleteCharacter(PlayerList[Player]->Chr); |
24 |
+ |
memset(PlayerList[Player], 0, sizeof(player_info)); |
25 |
+ |
PlayerList[Player] = 0; |
26 |
+ |
if(server_started) |
27 |
+ |
{ |
28 |
+ |
FLsPublic_Event( EV_DISCONNECT, &Player ); |
29 |
+ |
} |
30 |
+ |
} |
31 |
+ |
|
32 |
|
void DoRareSync( short Player, sockaddr_in * sender ) |
33 |
|
{ |
34 |
|
flatline_packet sync = {0}; |
87 |
|
|
88 |
|
//if(Players[i].ip == sender.sin_addr.S_un.S_addr) break; //needs to send an error message |
89 |
|
sender.sin_addr.S_un.S_addr = htonl(sender.sin_addr.S_un.S_addr); |
90 |
< |
playah = FLrServer_AddPlayer(from,packet->connect_send.name, 0); |
90 |
> |
playah = FLrServer_AddPlayer(from,packet->connect_send.name, 0, 0); |
91 |
|
DDrConsole_PrintF("%s connected from %s", packet->connect_send.name, inet_ntoa(sender.sin_addr ) ); |
92 |
|
if(!((int)playah > -5 && (int)playah <= 0)) { |
93 |
|
flatline_packet new_char = {0}; |
109 |
|
memset(Char, 0, sizeof(CharacterObject)); |
110 |
|
Char->Header.Type = 'CHAR'; |
111 |
|
Char->OSD.Options = chr_dontaim; |
112 |
+ |
//Build the NEWCHARACTERs for the new player |
113 |
|
for(j = 0; j < max_connections; j++) { |
114 |
|
if(PlayerList[j] != 0) { |
115 |
|
new_char.new_player.Playernumber = j; |
214 |
|
case RARE_SYNC_DATA_REQUEST: |
215 |
|
DoRareSync( packet->sync_request , &sender); |
216 |
|
break; |
217 |
+ |
case NULL_PACKET: |
218 |
+ |
if(1) |
219 |
+ |
{ |
220 |
+ |
int p; |
221 |
+ |
char arr[9999]; |
222 |
+ |
for (p = 0; p < datalen; p++) |
223 |
+ |
{ |
224 |
+ |
sprintf(arr,"%x",((char*)&packet)[p]); |
225 |
+ |
} |
226 |
+ |
DDrStartupMessage(arr); |
227 |
+ |
} |
228 |
+ |
break; |
229 |
|
default: |
230 |
|
DDrConsole_PrintF("Warning, recieved badly formed packet!"); |
231 |
|
break; |
233 |
|
return true; |
234 |
|
} |
235 |
|
|
236 |
+ |
void* TSrScores = 0; |
237 |
+ |
|
238 |
+ |
void FLrInit_Scores() |
239 |
+ |
{ |
240 |
+ |
void* TSFFTahoma; |
241 |
+ |
int returnval; |
242 |
+ |
|
243 |
+ |
if(!TSrScores){ |
244 |
+ |
TMrInstance_GetDataPtr( 'TSFF', "Tahoma", &TSFFTahoma); |
245 |
+ |
returnval = TSrContext_New( TSFFTahoma, 7, 1, 1, 0, &TSrScores); |
246 |
+ |
TSrContext_SetShade(TSrScores, 0xFFFFFFFF); |
247 |
+ |
} |
248 |
+ |
return; |
249 |
+ |
} |
250 |
+ |
|
251 |
+ |
void FLrRun_Scores() |
252 |
+ |
{ |
253 |
+ |
if(TSrScores) |
254 |
+ |
{ |
255 |
+ |
const int scores_top = 20; |
256 |
+ |
const int scores_left = 15; |
257 |
+ |
//Convert to grabbing the height directly plox |
258 |
+ |
const int line_height = 15; |
259 |
+ |
unsigned char alpha = 0xCC; |
260 |
+ |
unsigned int z; |
261 |
+ |
uint16_t point[2] = {scores_left,scores_top}; |
262 |
+ |
//TSrContext_DrawText(TSrScores, "Name HP/HP", 0xCC, 0, point); |
263 |
+ |
point[0] += 20; |
264 |
+ |
TSrContext_DrawText(TSrScores, "Name", alpha, 0, point); |
265 |
+ |
point[0] += 100; |
266 |
+ |
TSrContext_DrawText(TSrScores, "Dmg", alpha, 0, point); |
267 |
+ |
point[0] += 30; |
268 |
+ |
TSrContext_DrawText(TSrScores, "K", alpha, 0, point); |
269 |
+ |
point[0] += 30; |
270 |
+ |
TSrContext_DrawText(TSrScores, "D", alpha, 0, point); |
271 |
+ |
point[0] += 30; |
272 |
+ |
TSrContext_DrawText(TSrScores, "Health", alpha, 0, point); |
273 |
+ |
point[0] = scores_left; |
274 |
+ |
|
275 |
+ |
point[1] += line_height; |
276 |
+ |
for(z = 0; z < MAX_CONNECTIONS; z++) |
277 |
+ |
{ |
278 |
+ |
if(PlayerList[z]) |
279 |
+ |
{ |
280 |
+ |
|
281 |
+ |
char tempString[32]; |
282 |
+ |
|
283 |
+ |
sprintf(tempString, "%i", z); |
284 |
+ |
TSrContext_DrawText(TSrScores, tempString, alpha, 0, point); |
285 |
+ |
point[0] += 20; |
286 |
+ |
|
287 |
+ |
|
288 |
+ |
TSrContext_DrawText(TSrScores, PlayerList[z]->Chr->Name, alpha, 0, point); |
289 |
+ |
point[0] += 100; |
290 |
+ |
|
291 |
+ |
sprintf(tempString, "%i", PlayerList[z]->Chr->Damage); |
292 |
+ |
TSrContext_DrawText(TSrScores, tempString, alpha, 0, point); |
293 |
+ |
point[0] += 30; |
294 |
+ |
sprintf(tempString, "%i", PlayerList[z]->Chr->Kills); |
295 |
+ |
TSrContext_DrawText(TSrScores, tempString, alpha, 0, point); |
296 |
+ |
point[0] += 30; |
297 |
+ |
sprintf(tempString, "%i", PlayerList[z]->player_data.Deaths); |
298 |
+ |
TSrContext_DrawText(TSrScores, tempString, alpha, 0, point); |
299 |
+ |
point[0] += 30; |
300 |
+ |
if(PlayerList[z]->Chr->Health) |
301 |
+ |
{ |
302 |
+ |
sprintf(tempString, "%i", PlayerList[z]->Chr->Health); |
303 |
+ |
TSrContext_DrawText(TSrScores, tempString, alpha, 0, point); |
304 |
+ |
point[0] += 25; |
305 |
+ |
sprintf(tempString, "/%i", PlayerList[z]->Chr->MaxHealth); |
306 |
+ |
TSrContext_DrawText(TSrScores, tempString, alpha, 0, point); |
307 |
+ |
} |
308 |
+ |
else |
309 |
+ |
{ |
310 |
+ |
TSrContext_SetShade(TSrScores, 0x00FF0000); |
311 |
+ |
TSrContext_DrawText(TSrScores, "DEAD", alpha, 0, point); |
312 |
+ |
TSrContext_SetShade(TSrScores, 0xFFFFFFFF); |
313 |
+ |
} |
314 |
+ |
point[0] = scores_left; |
315 |
+ |
point[1] += line_height; |
316 |
+ |
} |
317 |
+ |
} |
318 |
+ |
} |
319 |
+ |
} |
320 |
+ |
|
321 |
|
bool FLrServer_Run() |
322 |
|
{ |
323 |
|
// Get the local hostname |
324 |
|
char szHostName[255]; |
325 |
|
struct hostent *host_entry; |
326 |
|
gethostname(szHostName, 255); |
327 |
< |
|
327 |
> |
FLrInit_Scores(); |
328 |
|
host_entry=gethostbyname(szHostName); |
329 |
|
DDrConsole_PrintF("Server started at %s...", inet_ntoa (*(struct in_addr *)*host_entry->h_addr_list)); |
330 |
|
return NetUDPServer_Listen(27777, FLrServer_PacketCallback); |
396 |
|
{ |
397 |
|
ActiveCharacter * Active; |
398 |
|
flatline_packet packet; |
399 |
+ |
FLrInit_Scores(); |
400 |
|
//#define SPAM_INPUT |
401 |
|
#ifdef SPAM_INPUT |
402 |
|
struct timeval lasttime; |
440 |
|
case MESSAGE: |
441 |
|
COrMessage_Print(packet.data, "chat", 0); |
442 |
|
break; |
443 |
+ |
case NULL_PACKET: |
444 |
+ |
if(1) |
445 |
+ |
{ |
446 |
+ |
int p; |
447 |
+ |
char arr[9999]; |
448 |
+ |
for (p = 0; p < len; p++) |
449 |
+ |
{ |
450 |
+ |
sprintf(arr,"%x",((char*)&packet)[p]); |
451 |
+ |
} |
452 |
+ |
DDrStartupMessage(arr); |
453 |
+ |
} |
454 |
+ |
break; |
455 |
|
case CONNECT_SEND: |
456 |
|
;if(1) { |
457 |
|
flatline_packet connect_recv; |
463 |
|
case NEW_PLAYER: |
464 |
|
;if(1) { //haxhaxhax |
465 |
|
CharacterObject* Char = &(packet.new_player.Character); |
466 |
< |
uint32_t chr_index = 0; |
466 |
> |
uint32_t chr_index = packet.new_player.Playernumber; |
467 |
|
Character* PC; |
468 |
|
DDrConsole_PrintF("%i | %i", packet.new_player.Playernumber ,client_slot); |
469 |
|
//Char->OSD.Options = 0; |
475 |
|
} |
476 |
|
else { |
477 |
|
ONrGameState_NewCharacter(Char, NULL, NULL, &chr_index); |
478 |
< |
ONgGameState->CharacterStorage[chr_index].field_1E8 = 0; |
478 |
> |
ONgGameState->CharacterStorage[chr_index].charType = 0; |
479 |
|
PlayerList[packet.new_player.Playernumber] = &Players[chr_index]; |
480 |
|
Players[chr_index].Chr = &(ONgGameState->CharacterStorage[chr_index]); |
481 |
|
Players[chr_index].Chr->Flags &= 0xFFBFFFFF; |
482 |
+ |
Players[chr_index].Chr->MaxHealth = 200; |
483 |
|
Players[chr_index].spawnnumber = chr_index; |
484 |
|
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) ; |
485 |
|
} |
528 |
|
flatline_packet sync_request = {0}; |
529 |
|
sync_request.id = RARE_SYNC_DATA_REQUEST; |
530 |
|
sync_request.sync_request = i; |
531 |
< |
DDrConsole_PrintF( "Requesting sync data for player %i, old index %u", i, PlayerList[i]->rare_sync_index); |
531 |
> |
//DDrConsole_PrintF( "Requesting sync data for player %i, old index %u, new index %i", i, PlayerList[i]->rare_sync_index, data->rare_sync_index); |
532 |
|
sent_bytes = NetUDPSocket_Send(client_sock,(sockaddr *) &address, (char*)&sync_request, FLATLINE_HEADER + sizeof(int) ); |
533 |
|
} |
534 |
|
|
595 |
|
PlayerList[i]->rare_sync_index = packet.rare_sync_data.index; |
596 |
|
} |
597 |
|
break; |
598 |
< |
|
598 |
> |
case FLATLINE_EVENT: |
599 |
> |
FLcEvent_Handler(packet.flatline_event.event_index, packet.flatline_event.intArray); |
600 |
|
default: |
601 |
|
DDrConsole_PrintF("Warning, recieved badly formed packet!"); |
602 |
|
break; |
631 |
|
} |
632 |
|
return -1; |
633 |
|
} |
634 |
< |
typedef struct |
635 |
< |
{ |
636 |
< |
uint16_t x; |
637 |
< |
uint16_t y; |
638 |
< |
|
634 |
> |
typedef struct |
635 |
> |
{ |
636 |
> |
uint16_t x; |
637 |
> |
uint16_t y; |
638 |
> |
|
639 |
|
} IMtPoint2D; |
640 |
|
static flatline_packet cache_input = {0}; |
641 |
|
extern void* TSrTest; |
642 |
+ |
|
643 |
+ |
void ONrCharacter_SetAnimationInternal(Character *ioCharacter, ActiveCharacter *ioActiveCharacter, |
644 |
+ |
short inFromState, short inNextAnimType, const void *inAnimation) |
645 |
+ |
{ |
646 |
+ |
void *characterClass = ioCharacter->ONCC; |
647 |
+ |
//void *collection = ioCharacter->characterClass; |
648 |
+ |
short index = ioCharacter->Number;//ONrCharacter_GetIndex(ioCharacter); |
649 |
+ |
short animType; |
650 |
+ |
if(inAnimation == NULL) return; |
651 |
+ |
//UUmAssert(NULL != inAnimation); |
652 |
+ |
|
653 |
+ |
animType = *((char*)inAnimation + 0x15A); |
654 |
+ |
|
655 |
+ |
ioActiveCharacter->Animation = inAnimation; |
656 |
+ |
ioActiveCharacter->Frame = 0; |
657 |
+ |
ioActiveCharacter->AnimationFromState = inFromState; |
658 |
+ |
ioActiveCharacter->AnimationType = animType; |
659 |
+ |
ioActiveCharacter->NextAnimationType = inNextAnimType; |
660 |
+ |
ioActiveCharacter->AnimationToState = TRrAnimation_GetTo((void *)inAnimation); |
661 |
+ |
|
662 |
+ |
//UUmAssertTrigRange(ioCharacter->facing); |
663 |
+ |
|
664 |
+ |
/* if (gDebugCharacters && (index == gDebugCharacterTarget)) { |
665 |
+ |
COrConsole_Printf("anim %s state %s type %s length %d", |
666 |
+ |
TRrAnimation_GetName(inAnimation), |
667 |
+ |
ONrAnimStateToString(TRrAnimation_GetTo(inAnimation)), |
668 |
+ |
ONrAnimTypeToString(TRrAnimation_GetType(inAnimation)), |
669 |
+ |
TRrAnimation_GetDuration(inAnimation)); |
670 |
+ |
}*/ |
671 |
+ |
|
672 |
+ |
return; |
673 |
+ |
} |
674 |
+ |
|
675 |
+ |
char ONrAnimState_IsFallen(short inAnimState) |
676 |
+ |
{ |
677 |
+ |
char result = false; |
678 |
+ |
|
679 |
+ |
switch(inAnimState) |
680 |
+ |
{ |
681 |
+ |
case 18://ONcAnimState_Fallen_Back: |
682 |
+ |
case 50://ONcAnimState_Fallen_Front: |
683 |
+ |
result = true; |
684 |
+ |
break; |
685 |
+ |
} |
686 |
+ |
|
687 |
+ |
return result; |
688 |
+ |
} |
689 |
+ |
|
690 |
+ |
void FLrRespawn(int i) |
691 |
+ |
{ |
692 |
+ |
DDrConsole_Print( "Respawn!"); |
693 |
+ |
ONrCorpse_Create(PlayerList[i]->Chr); |
694 |
+ |
ONrCharacter_SetHitPoints( PlayerList[i]->Chr, PlayerList[i]->Chr->MaxHealth); |
695 |
+ |
} |
696 |
|
void * ONICALL FLrInput_Update_Keys(void) |
697 |
|
{ |
698 |
|
uint16_t i; |
704 |
|
); |
705 |
|
*/ |
706 |
|
ActiveCharacter * Active_Player = ONgGameState->ActiveCharacters; |
707 |
< |
Active_Player->PhyContext->Rotation; |
708 |
< |
Active_Player->PhyContext->Position; |
709 |
< |
ONgGameState->PlayerCharacter->Position; |
707 |
> |
//Active_Player->PhyContext->Rotation; |
708 |
> |
//Active_Player->PhyContext->Position; |
709 |
> |
//ONgGameState->PlayerCharacter->Position; |
710 |
|
|
711 |
|
|
712 |
|
|
743 |
|
//return ONgGameState; |
744 |
|
} |
745 |
|
#endif |
746 |
< |
//Testing drawing text to the screen...this failed. Will need to get it working eventually. |
567 |
< |
if( TSrTest ) |
568 |
< |
{ |
569 |
< |
// OniRectangle TextRect = { 128, 128, 256, 256 }; |
570 |
< |
IMtPoint2D Point = {50, 50}; |
571 |
< |
//TSrContext_DrawText(TSrTest, "Testing woohoo", 255, 0, &Point); |
572 |
< |
TSrContext_DrawText(TSrTest, "WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW", 255, 0, &Point); |
573 |
< |
|
574 |
< |
} |
746 |
> |
|
747 |
|
if(!(server_started || client_connected)) return ONgGameState; |
748 |
|
|
749 |
|
for(i = 0; i < max_connections; i++) { |
750 |
|
ActiveCharacter * Active_Player; |
751 |
|
GameInput * Active_Input; |
752 |
|
if(PlayerList[i] == 0) continue; |
753 |
< |
|
754 |
< |
//is this right? |
755 |
< |
Active_Player = (void*)ONrGetActiveCharacter( PlayerList[i]->Chr); |
756 |
< |
|
757 |
< |
if(Active_Player == 0) continue; |
758 |
< |
Active_Input = &(Active_Player->Input); |
759 |
< |
if(server_started) { |
760 |
< |
player_data * data; |
761 |
< |
flatline_packet data_out = {0}; |
762 |
< |
|
763 |
< |
//if( PlayerList[i]->Chr->Health == 0) PlayerList[i]->Chr->Health = PlayerList[i]->Chr->MaxHealth; |
764 |
< |
|
765 |
< |
data_out.id = PLAYER_DATA; |
766 |
< |
data = (void*)&(data_out.data); |
767 |
< |
data->PlayerNum = i; |
596 |
< |
data->Health = PlayerList[i]->Chr->Health; |
597 |
< |
data->MaxHealth = PlayerList[i]->Chr->MaxHealth; |
598 |
< |
data->Position = PlayerList[i]->Chr->Position; |
599 |
< |
data->Location = PlayerList[i]->Chr->Location; |
600 |
< |
data->LastPosition = PlayerList[i]->Chr->LastPosition; |
601 |
< |
data->Facing = PlayerList[i]->Chr->Facing; |
602 |
< |
data->DesiredFacing = PlayerList[i]->Chr->DesiredFacing; |
603 |
< |
data->CosmeticFacing = PlayerList[i]->Chr->CosmeticFacing; |
604 |
< |
|
605 |
< |
|
606 |
< |
data->Position = Active_Player->PhyContext->Position; |
607 |
< |
|
608 |
< |
if( PlayerList[i]->OldClass != PlayerList[i]->Chr->ONCC || memcmp( &(PlayerList[i]->Inventory), &(PlayerList[i]->Chr->Inventory), sizeof(Inventory) ) ) |
753 |
> |
if( !PlayerList[i]->Chr || (PlayerList[i]->flags == PF_SCRIPTEDAI && PlayerList[i]->Chr->Flags & ONcCharacterFlag_Dead ) ) |
754 |
> |
{ |
755 |
> |
PlayerDisconnect(i); |
756 |
> |
continue; |
757 |
> |
} |
758 |
> |
PlayerList[i]->Chr->Inventory.Weapons[0] = 0; |
759 |
> |
PlayerList[i]->Chr->Inventory.Weapons[1] = 0; |
760 |
> |
PlayerList[i]->Chr->Inventory.Weapons[2] = 0; |
761 |
> |
if( !client_connected && PlayerList[i]->Chr->Flags & ONcCharacterFlag_Dead )//dead |
762 |
> |
{ |
763 |
> |
char doRespawn = false; |
764 |
> |
uint32_t Actions1Bitmask = Action_Punch | Action_Kick; |
765 |
> |
uint32_t Actions2Bitmask = Action2_Fire1 | Action2_Fire2; |
766 |
> |
if(client_connected) continue; |
767 |
> |
if(PlayerList[i]->state == STATE_ALIVE) |
768 |
|
{ |
769 |
< |
PlayerList[i]->OldClass = PlayerList[i]->Chr->ONCC; |
770 |
< |
memcpy( &(PlayerList[i]->Inventory), &(PlayerList[i]->Chr->Inventory), sizeof(Inventory) ); |
612 |
< |
PlayerList[i]->rare_sync_index++; |
613 |
< |
|
769 |
> |
PlayerList[i]->state = STATE_DEAD; |
770 |
> |
PlayerList[i]->player_data.Deaths++; |
771 |
|
} |
772 |
< |
|
773 |
< |
data->rare_sync_index = PlayerList[i]->rare_sync_index; |
774 |
< |
|
775 |
< |
#if 0 |
776 |
< |
data->Frame = Active_Player->Frame; |
620 |
< |
memcpy(data->Animation, TMrInstance_GetInstanceName(Active_Player->Animation), 32); |
621 |
< |
data->AnimationToState = Active_Player->AnimationToState; |
622 |
< |
data->AnimationFromState = Active_Player->AnimationFromState; |
623 |
< |
data->AnimationType = Active_Player->AnimationType; |
624 |
< |
data->NextAnimationType = Active_Player->NextAnimationType; |
625 |
< |
data->InterpolationCurrentFrame = Active_Player->InterpolationCurrentFrame; |
626 |
< |
data->InterpolationFromState = Active_Player->InterpolationFromState; |
627 |
< |
data->InterpolationLength = Active_Player->InterpolationLength; |
628 |
< |
memcpy(data->InterpolationStartRotations, Active_Player->InterpolationStartRotations, |
629 |
< |
sizeof(Quaternion) * 19); |
630 |
< |
// data->InterpolationStartRotations = Active_Player->InterpolationStartRotations; |
631 |
< |
memcpy(data->BoneMatrices, Active_Player->BoneMatrices, |
632 |
< |
sizeof(Quaternion) * 19); |
633 |
< |
data->Stitch = Active_Player->Stitch; |
634 |
< |
data->StitchHeight = Active_Player->StitchHeight; |
635 |
< |
data->StitchVelocity = Active_Player->StitchVelocity; |
636 |
< |
|
637 |
< |
data->Overlay = Active_Player->Overlay; |
638 |
< |
memcpy( data->OverlayRotations, Active_Player->OverlayRotations |
639 |
< |
,sizeof(Quaternion) * 19); |
640 |
< |
#endif |
641 |
< |
if(i == 0) { |
642 |
< |
data->Inputs.Actions1 = ((GameState*)(ONgGameState))->Input.Current.Actions1; |
643 |
< |
data->Inputs.Actions2 = ((GameState*)(ONgGameState))->Input.Current.Actions2; |
644 |
< |
data->Inputs.MouseDeltaX = ONgGameState->Input.MouseDeltaX; |
645 |
< |
data->Inputs.MouseDeltaY = ONgGameState->Input.MouseDeltaY; |
646 |
< |
} |
647 |
< |
else{ |
648 |
< |
data->Inputs.Actions1 = PlayerList[i]->Actions1; |
649 |
< |
data->Inputs.Actions2 = PlayerList[i]->Actions2; |
650 |
< |
data->Inputs.MouseDeltaX = PlayerList[i]->MouseDeltaX; |
651 |
< |
data->Inputs.MouseDeltaY = PlayerList[i]->MouseDeltaY; |
772 |
> |
if((i == 0 && ( ONgGameState->Input.Current.Actions1 & Actions1Bitmask || ONgGameState->Input.Current.Actions2 & Actions2Bitmask )) |
773 |
> |
|| (PlayerList[i]->Actions1 & Actions1Bitmask) || (PlayerList[i]->Actions2 & Actions2Bitmask) ) |
774 |
> |
{ |
775 |
> |
FLrRespawn(i); |
776 |
> |
PlayerList[i]->state = STATE_ALIVE; |
777 |
|
} |
778 |
< |
memcpy( &(PlayerList[i]->player_data), data, sizeof(player_data) ); |
654 |
< |
|
655 |
< |
UDPServer_SendToAll(&data_out, sizeof(player_data) + FLATLINE_HEADER); |
778 |
> |
continue; |
779 |
|
} |
780 |
< |
|
780 |
> |
else |
781 |
> |
{ |
782 |
> |
Active_Player = (void*)ONrGetActiveCharacter( PlayerList[i]->Chr); |
783 |
> |
// if(Active_Player == 0) continue; |
784 |
> |
//Active_Input = &(Active_Player->Input); |
785 |
> |
if(server_started) { |
786 |
> |
player_data * data; |
787 |
> |
flatline_packet data_out = {0}; |
788 |
> |
|
789 |
> |
//if( PlayerList[i]->Chr->Health == 0) PlayerList[i]->Chr->Health = PlayerList[i]->Chr->MaxHealth; |
790 |
> |
|
791 |
> |
data_out.id = PLAYER_DATA; |
792 |
> |
data = (void*)&(data_out.data); |
793 |
> |
data->Deaths = PlayerList[i]->player_data.Deaths; |
794 |
> |
data->PlayerNum = i; |
795 |
> |
data->Kills = PlayerList[i]->Chr->Kills; |
796 |
> |
data->Damage = PlayerList[i]->Chr->Damage; |
797 |
> |
data->Health = PlayerList[i]->Chr->Health; |
798 |
> |
data->MaxHealth = PlayerList[i]->Chr->MaxHealth; |
799 |
> |
data->Facing = PlayerList[i]->Chr->Facing; |
800 |
> |
data->DesiredFacing = PlayerList[i]->Chr->DesiredFacing; |
801 |
> |
if(Active_Player && Active_Player->PhyContext) |
802 |
> |
data->Position = Active_Player->PhyContext->Position; |
803 |
> |
|
804 |
> |
if( PlayerList[i]->OldClass != PlayerList[i]->Chr->ONCC || memcmp( &(PlayerList[i]->Inventory), &(PlayerList[i]->Chr->Inventory), sizeof(Inventory) ) ) |
805 |
> |
{ |
806 |
> |
PlayerList[i]->OldClass = PlayerList[i]->Chr->ONCC; |
807 |
> |
memcpy( &(PlayerList[i]->Inventory), &(PlayerList[i]->Chr->Inventory), sizeof(Inventory) ); |
808 |
> |
PlayerList[i]->rare_sync_index++; |
809 |
> |
|
810 |
> |
} |
811 |
> |
data->rare_sync_index = PlayerList[i]->rare_sync_index; |
812 |
> |
if(Active_Player) |
813 |
> |
{ |
814 |
> |
data->Frame = Active_Player->Frame; |
815 |
> |
memcpy(data->Animation, TMrInstance_GetInstanceName(Active_Player->Animation), 32); |
816 |
> |
|
817 |
> |
if(Active_Player->targetThrow) |
818 |
> |
{ |
819 |
> |
ActiveCharacter* Target = ONrGetActiveCharacter(Active_Player->ThrowTargetCharacter); |
820 |
> |
if(Target) |
821 |
> |
{ |
822 |
> |
data->throw_data.throwing = Players[Active_Player->throwing].list_slot; |
823 |
> |
data->throw_data.throwFrame = Target->Frame; |
824 |
> |
strcpy_s(data->throw_data.throwName, 32, TMrInstance_GetInstanceName(Active_Player->targetThrow)); |
825 |
> |
} |
826 |
> |
} |
827 |
> |
} |
828 |
> |
if(i == 0) { |
829 |
> |
data->Inputs.Actions1 = ((GameState*)(ONgGameState))->Input.Current.Actions1; |
830 |
> |
data->Inputs.Actions2 = ((GameState*)(ONgGameState))->Input.Current.Actions2; |
831 |
> |
data->Inputs.MouseDeltaX = ONgGameState->Input.MouseDeltaX; |
832 |
> |
data->Inputs.MouseDeltaY = ONgGameState->Input.MouseDeltaY; |
833 |
> |
} |
834 |
> |
else{ |
835 |
> |
data->Inputs.Actions1 = PlayerList[i]->Actions1; |
836 |
> |
data->Inputs.Actions2 = PlayerList[i]->Actions2; |
837 |
> |
data->Inputs.MouseDeltaX = PlayerList[i]->MouseDeltaX; |
838 |
> |
data->Inputs.MouseDeltaY = PlayerList[i]->MouseDeltaY; |
839 |
> |
} |
840 |
> |
memcpy( &(PlayerList[i]->player_data), data, sizeof(player_data) ); |
841 |
> |
|
842 |
> |
UDPServer_SendToAll(&data_out, sizeof(player_data) + FLATLINE_HEADER); |
843 |
> |
} |
844 |
> |
} |
845 |
> |
if(Active_Player == 0) continue; |
846 |
> |
else Active_Input = &(Active_Player->Input); |
847 |
|
if( (server_started && i !=0) || (!server_started/* && i != client_slot*/) ) |
848 |
|
{ |
660 |
– |
//this just made sync even worse... |
661 |
– |
#ifdef JITTER_FIX |
662 |
– |
input_struct * New_Input = &PlayerList[i]->MouseDeltaX; |
663 |
– |
input_struct * Cache_Input = &PlayerList[i]->CacheInput; |
664 |
– |
Active_Input->Stop.Actions1 = ~Cache_Input->Actions1 & Active_Input->Current.Actions1; |
665 |
– |
Active_Input->Stop.Actions2 = ~Cache_Input->Actions2 & Active_Input->Current.Actions2; |
666 |
– |
Active_Input->Start.Actions1 = ~Active_Input->Current.Actions1 & Cache_Input->Actions1; |
667 |
– |
Active_Input->Start.Actions2 = ~Active_Input->Current.Actions2 & Cache_Input->Actions2; |
668 |
– |
Active_Input->Current.Actions1 = Cache_Input->Actions1; |
669 |
– |
Active_Input->Current.Actions2 = Cache_Input->Actions2; |
670 |
– |
Active_Input->Stopped.Actions1 = ~Active_Input->Current.Actions1; |
671 |
– |
Active_Input->Stopped.Actions2 = ~Active_Input->Current.Actions2; |
672 |
– |
Active_Input->MouseDeltaX = Cache_Input->MouseDeltaX; |
673 |
– |
Active_Input->MouseDeltaY = Cache_Input->MouseDeltaY; |
674 |
– |
memcpy( Cache_Input, New_Input, sizeof(input_struct)); |
675 |
– |
#else |
676 |
– |
|
849 |
|
Active_Input->Stop.Actions1 = ~PlayerList[i]->Actions1 & Active_Input->Current.Actions1; |
850 |
|
Active_Input->Stop.Actions2 = ~PlayerList[i]->Actions2 & Active_Input->Current.Actions2; |
851 |
|
Active_Input->Start.Actions1 = ~Active_Input->Current.Actions1 & PlayerList[i]->Actions1; |
870 |
|
); |
871 |
|
*/ |
872 |
|
|
873 |
< |
|
874 |
< |
#endif |
873 |
> |
if( !server_started ) |
874 |
> |
{ |
875 |
> |
if(PlayerList[i]->player_data.Health != 0) |
876 |
> |
{ |
877 |
> |
Character* character = PlayerList[i]->Chr; |
878 |
> |
void* animation; |
879 |
> |
void* prev_character_animation = Active_Player->Animation; |
880 |
> |
int error; |
881 |
> |
td* throw_data= &PlayerList[i]->player_data.throw_data; |
882 |
> |
|
883 |
> |
if(PlayerList[i]->Chr->Flags & ONcCharacterFlag_Dead) |
884 |
> |
{ |
885 |
> |
FLrRespawn(i); |
886 |
> |
} |
887 |
|
|
888 |
< |
#ifdef BETTER_SYNC |
889 |
< |
if( !server_started && PlayerList[i]->player_data.Health != 0) { |
890 |
< |
PlayerList[i]->Chr->Health = PlayerList[i]->player_data.Health; |
891 |
< |
PlayerList[i]->Chr->MaxHealth = PlayerList[i]->player_data.MaxHealth; |
892 |
< |
PlayerList[i]->Chr->Position = PlayerList[i]->player_data.Position; |
893 |
< |
PlayerList[i]->Chr->Location = PlayerList[i]->player_data.Location; |
894 |
< |
PlayerList[i]->Chr->LastPosition = PlayerList[i]->player_data.LastPosition; |
895 |
< |
PlayerList[i]->Chr->Facing = PlayerList[i]->player_data.Facing; |
896 |
< |
PlayerList[i]->Chr->DesiredFacing = PlayerList[i]->player_data.DesiredFacing; |
897 |
< |
PlayerList[i]->Chr->CosmeticFacing = PlayerList[i]->player_data.CosmeticFacing; |
898 |
< |
PlayerList[i]->Actions1 = PlayerList[i]->player_data.Inputs.Actions1; |
899 |
< |
PlayerList[i]->Actions2 = PlayerList[i]->player_data.Inputs.Actions2; |
900 |
< |
PlayerList[i]->MouseDeltaX = PlayerList[i]->player_data.Inputs.MouseDeltaX; |
901 |
< |
PlayerList[i]->MouseDeltaY = PlayerList[i]->player_data.Inputs.MouseDeltaY; |
902 |
< |
Active_Player->PhyContext->Position = PlayerList[i]->player_data.Position; |
903 |
< |
} |
904 |
< |
#endif |
888 |
> |
PlayerList[i]->Chr->Health = PlayerList[i]->player_data.Health; |
889 |
> |
PlayerList[i]->Chr->MaxHealth = PlayerList[i]->player_data.MaxHealth; |
890 |
> |
PlayerList[i]->Chr->Facing = PlayerList[i]->player_data.Facing; |
891 |
> |
PlayerList[i]->Chr->DesiredFacing = PlayerList[i]->player_data.DesiredFacing; |
892 |
> |
PlayerList[i]->Actions1 = PlayerList[i]->player_data.Inputs.Actions1; |
893 |
> |
PlayerList[i]->Actions2 = PlayerList[i]->player_data.Inputs.Actions2; |
894 |
> |
PlayerList[i]->MouseDeltaX = PlayerList[i]->player_data.Inputs.MouseDeltaX; |
895 |
> |
PlayerList[i]->MouseDeltaY = PlayerList[i]->player_data.Inputs.MouseDeltaY; |
896 |
> |
PlayerList[i]->Chr->Damage = PlayerList[i]->player_data.Damage; |
897 |
> |
PlayerList[i]->Chr->Kills = PlayerList[i]->player_data.Kills; |
898 |
> |
if(Active_Player->PhyContext) |
899 |
> |
Active_Player->PhyContext->Position = PlayerList[i]->player_data.Position; |
900 |
> |
|
901 |
> |
if (!(character->Flags & ONcCharacterFlag_BeingThrown/*ONcCharacterFlag_BeingThrown*/) && |
902 |
> |
(PlayerList[i]->player_data.Animation[0] != '\0')) |
903 |
> |
{ |
904 |
> |
// get a pointer to the animation |
905 |
> |
error = |
906 |
> |
TMrInstance_GetDataPtr( |
907 |
> |
'TRAM', |
908 |
> |
PlayerList[i]->player_data.Animation, |
909 |
> |
&animation); |
910 |
> |
if (error == 0) |
911 |
> |
{ |
912 |
> |
short num_frames; |
913 |
> |
char updateAnimation = true; |
914 |
> |
|
915 |
> |
// if the character is dead, make sure this animation is appropriate for death |
916 |
> |
if (character->Flags & 0x00000001) |
917 |
> |
{ |
918 |
> |
int curToState = TRrAnimation_GetTo(Active_Player->Animation); |
919 |
> |
int newToState = TRrAnimation_GetTo(animation); |
920 |
> |
|
921 |
> |
// if we are currently heading towards fallen and the new animation would not |
922 |
> |
// then this is a better animation to run when we are dead |
923 |
> |
if ((ONrAnimState_IsFallen(curToState)) && |
924 |
> |
(!ONrAnimState_IsFallen(newToState))) |
925 |
> |
{ |
926 |
> |
updateAnimation = false; |
927 |
> |
} |
928 |
> |
} |
929 |
> |
|
930 |
> |
if ((updateAnimation) && (Active_Player->Animation == animation)) |
931 |
> |
{ |
932 |
> |
int oldFrame = Active_Player->Frame; |
933 |
> |
int newFrame = PlayerList[i]->player_data.Frame; |
934 |
> |
|
935 |
> |
if (abs(oldFrame - newFrame) < 2) |
936 |
> |
{ |
937 |
> |
updateAnimation = false; |
938 |
> |
} |
939 |
> |
} |
940 |
> |
|
941 |
> |
if (updateAnimation) |
942 |
> |
{ |
943 |
> |
// set the characters animation |
944 |
> |
ONrCharacter_SetAnimationInternal( |
945 |
> |
character, Active_Player, |
946 |
> |
TRrAnimation_GetFrom(Active_Player->Animation), |
947 |
> |
0, |
948 |
> |
animation); |
949 |
> |
//PlayerList[i]->player_data.Animation[0] = 0; |
950 |
> |
} |
951 |
> |
|
952 |
> |
num_frames = TRrAnimation_GetDuration(Active_Player->Animation); |
953 |
> |
|
954 |
> |
if (PlayerList[i]->player_data.Frame >= num_frames) |
955 |
> |
{ |
956 |
> |
Active_Player->Frame = num_frames - 1; |
957 |
> |
} |
958 |
> |
else |
959 |
> |
{ |
960 |
> |
Active_Player->Frame = PlayerList[i]->player_data.Frame ; |
961 |
> |
} |
962 |
> |
} |
963 |
> |
} |
964 |
|
|
965 |
+ |
if (throw_data->throwName[0] && PlayerList[throw_data->throwing]) |
966 |
+ |
{ |
967 |
+ |
int realIndex = PlayerList[throw_data->throwing]->Chr->Number; |
968 |
+ |
if ((throw_data->throwing != 0xFFFF) && |
969 |
+ |
(realIndex != Active_Player->throwing) && |
970 |
+ |
(throw_data->throwFrame < 10)) |
971 |
+ |
{ |
972 |
+ |
void *throw_animation; |
973 |
+ |
ActiveCharacter* Target; |
974 |
+ |
|
975 |
+ |
// get the animation |
976 |
+ |
error = |
977 |
+ |
TMrInstance_GetDataPtr( |
978 |
+ |
'TRAM', |
979 |
+ |
throw_data->throwName, |
980 |
+ |
&throw_animation); |
981 |
+ |
if (error != 0) return ONgGameState; |
982 |
+ |
|
983 |
+ |
// set the throw target |
984 |
+ |
Active_Player->ThrowTargetCharacter = &ONgGameState->CharacterStorage[realIndex]; |
985 |
+ |
Target = ONrGetActiveCharacter(Active_Player->ThrowTargetCharacter); |
986 |
+ |
if(Target) |
987 |
+ |
{ |
988 |
+ |
if ((Target->Animation != throw_animation) && |
989 |
+ |
(prev_character_animation != animation) && |
990 |
+ |
!(Active_Player->ThrowTargetCharacter->Flags & ONcCharacterFlag_BeingThrown)) |
991 |
+ |
{ |
992 |
+ |
// set the throw variables |
993 |
+ |
Active_Player->targetThrow = throw_animation; |
994 |
+ |
Active_Player->throwing = realIndex; |
995 |
+ |
|
996 |
+ |
// run the throw |
997 |
+ |
ONrCharacter_NewAnimationHook(character, Active_Player); |
998 |
+ |
if (Active_Player->ThrowTargetCharacter) |
999 |
+ |
{ |
1000 |
+ |
Target->Frame += 2; |
1001 |
+ |
Target->thrownBy = character->Number; |
1002 |
+ |
DDrConsole_PrintF("Thrownby %i!!!!", Target->thrownBy); |
1003 |
+ |
DDrStartupMessage("Thrownby %i!!!!", Target->thrownBy); |
1004 |
+ |
} |
1005 |
+ |
} |
1006 |
+ |
} |
1007 |
+ |
} |
1008 |
+ |
} |
1009 |
+ |
} |
1010 |
+ |
|
1011 |
+ |
} |
1012 |
|
} |
1013 |
|
} |
1014 |
|
|
1015 |
|
return ONgGameState; |
1016 |
+ |
} |
1017 |
+ |
|
1018 |
+ |
int EventPlusArgs[EV_MAX + 1][2] = |
1019 |
+ |
{ |
1020 |
+ |
{EV_RESPAWN, 1}, |
1021 |
+ |
{EV_DISCONNECT, 1}, |
1022 |
+ |
{EV_DOOR_OPEN, 1}, |
1023 |
+ |
{EV_MAX, 0}, |
1024 |
+ |
}; |
1025 |
+ |
|
1026 |
+ |
int FLrEvent_GetNumArgs( int eventIndex ) |
1027 |
+ |
{ |
1028 |
+ |
return EventPlusArgs[1][eventIndex]; |
1029 |
+ |
|
1030 |
+ |
} |
1031 |
+ |
|
1032 |
+ |
char * FLrHook_DoorOpen( DoorObject *inDoor, Character *Char) |
1033 |
+ |
{ |
1034 |
+ |
if(server_started) |
1035 |
+ |
{ |
1036 |
+ |
FLsPublic_Event( EV_DOOR_OPEN, &inDoor->Door.ID ); |
1037 |
+ |
} |
1038 |
+ |
return (inDoor->Door.class); |
1039 |
|
} |