Rev 1 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1 | Rev 18 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | #include "pd/net.h" |
1 | #include "pd/net.h" |
2 | 2 | ||
3 | #include " |
3 | #include "brender.h" |
4 | #include "dr_types.h" |
4 | #include "dr_types.h" |
5 | #include "errors.h" |
5 | #include "errors.h" |
6 | #include "globvrpb.h" |
6 | #include "globvrpb.h" |
7 | #include "harness/config.h" |
7 | #include "harness/config.h" |
8 | #include "harness/hooks.h" |
8 | #include "harness/hooks.h" |
Line 53... | Line 53... | ||
53 | struct sockaddr_in gLast_received_addr; |
53 | struct sockaddr_in gLast_received_addr; |
54 | int gSocket; |
54 | int gSocket; |
55 | 55 | ||
56 | #define MESSAGE_HEADER_STR "CW95MSG" |
56 | #define MESSAGE_HEADER_STR "CW95MSG" |
57 | #define JOINABLE_GAMES_CAPACITY 16 |
57 | #define JOINABLE_GAMES_CAPACITY 16 |
- | 58 | ||
- | 59 | DR_STATIC_ASSERT(offsetof(tNet_message, pd_stuff_so_DO_NOT_USE) == 0); |
|
- | 60 | DR_STATIC_ASSERT(offsetof(tNet_message, magic_number) == 4); |
|
- | 61 | DR_STATIC_ASSERT(offsetof(tNet_message, guarantee_number) == 8); |
|
- | 62 | DR_STATIC_ASSERT(offsetof(tNet_message, sender) == 12); |
|
- | 63 | DR_STATIC_ASSERT(offsetof(tNet_message, version) == 16); |
|
- | 64 | DR_STATIC_ASSERT(offsetof(tNet_message, senders_time_stamp) == 20); |
|
- | 65 | DR_STATIC_ASSERT(offsetof(tNet_message, num_contents) == 24); |
|
- | 66 | DR_STATIC_ASSERT(offsetof(tNet_message, overall_size) == 26); |
|
- | 67 | DR_STATIC_ASSERT(offsetof(tNet_message, contents) == 28); |
|
58 | 68 | ||
59 | // IDA: void __cdecl ClearupPDNetworkStuff() |
69 | // IDA: void __cdecl ClearupPDNetworkStuff() |
60 | void ClearupPDNetworkStuff(void) { |
70 | void ClearupPDNetworkStuff(void) { |
61 | LOG_TRACE("()"); |
71 | LOG_TRACE("()"); |
62 | NOT_IMPLEMENTED(); |
72 | NOT_IMPLEMENTED(); |
Line 126... | Line 136... | ||
126 | 136 | ||
127 | int SameEthernetAddress(struct sockaddr_in* pAddr_ipx1, struct sockaddr_in* pAddr_ipx2) { |
137 | int SameEthernetAddress(struct sockaddr_in* pAddr_ipx1, struct sockaddr_in* pAddr_ipx2) { |
128 | LOG_TRACE("(%p, %p)", pAddr_ipx1, pAddr_ipx2); |
138 | LOG_TRACE("(%p, %p)", pAddr_ipx1, pAddr_ipx2); |
129 | 139 | ||
130 | return memcmp(pAddr_ipx1, pAddr_ipx2, sizeof(struct sockaddr_in)) == 0; |
140 | return memcmp(pAddr_ipx1, pAddr_ipx2, sizeof(struct sockaddr_in)) == 0; |
131 | } |
141 | } |
132 | 142 | ||
133 | /*SOCKADDR_IPX_* */ void* GetIPXAddrFromPlayerID(tPlayer_ID pPlayer_id) { |
143 | /*SOCKADDR_IPX_* */ void* GetIPXAddrFromPlayerID(tPlayer_ID pPlayer_id) { |
134 | //int i; // Pierre-Marie Baty -- unused variable |
144 | //int i; // Pierre-Marie Baty -- unused variable |
135 | //tU8* nodenum; // Pierre-Marie Baty -- unused variable |
145 | //tU8* nodenum; // Pierre-Marie Baty -- unused variable |
136 | NOT_IMPLEMENTED(); |
146 | NOT_IMPLEMENTED(); |
137 | } |
147 | } |
Line 419... | Line 429... | ||
419 | int i; |
429 | int i; |
420 | int j; |
430 | int j; |
421 | int number_of_hosts_has_changed; |
431 | int number_of_hosts_has_changed; |
422 | //char str[256]; // Pierre-Marie Baty -- unused variable |
432 | //char str[256]; // Pierre-Marie Baty -- unused variable |
423 | LOG_TRACE9("(%p, %d)", pGame, pIndex); |
433 | LOG_TRACE9("(%p, %d)", pGame, pIndex); |
424 | 434 | ||
425 | dr_dprintf("PDNetGetNextJoinGame(): pIndex is %d", pIndex); |
435 | dr_dprintf("PDNetGetNextJoinGame(): pIndex is %d", pIndex); |
426 | if (pIndex == 0) { |
436 | if (pIndex == 0) { |
427 | do { |
437 | do { |
428 | number_of_hosts_has_changed = 0; |
438 | number_of_hosts_has_changed = 0; |
429 | for (i = 0; i < gNumber_of_hosts; i++) { |
439 | for (i = 0; i < gNumber_of_hosts; i++) { |
Line 474... | Line 484... | ||
474 | int PDNetJoinGame(tNet_game_details* pDetails, char* pPlayer_name) { |
484 | int PDNetJoinGame(tNet_game_details* pDetails, char* pPlayer_name) { |
475 | LOG_TRACE("(%p, \"%s\")", pDetails, pPlayer_name); |
485 | LOG_TRACE("(%p, \"%s\")", pDetails, pPlayer_name); |
476 | 486 | ||
477 | dr_dprintf("PDNetJoinGame()"); |
487 | dr_dprintf("PDNetJoinGame()"); |
478 | return 0; |
488 | return 0; |
479 | } |
489 | } |
480 | 490 | ||
481 | // IDA: void __usercall PDNetLeaveGame(tNet_game_details *pDetails@<EAX>) |
491 | // IDA: void __usercall PDNetLeaveGame(tNet_game_details *pDetails@<EAX>) |
482 | void PDNetLeaveGame(tNet_game_details* pDetails) { |
492 | void PDNetLeaveGame(tNet_game_details* pDetails) { |
483 | LOG_TRACE("(%p)", pDetails); |
493 | LOG_TRACE("(%p)", pDetails); |
484 | 494 | ||
Line 492... | Line 502... | ||
492 | dr_dprintf("PDNetHostFinishGame()"); |
502 | dr_dprintf("PDNetHostFinishGame()"); |
493 | } |
503 | } |
494 | 504 | ||
495 | // IDA: tU32 __usercall PDNetExtractGameID@<EAX>(tNet_game_details *pDetails@<EAX>) |
505 | // IDA: tU32 __usercall PDNetExtractGameID@<EAX>(tNet_game_details *pDetails@<EAX>) |
496 | tU32 PDNetExtractGameID(tNet_game_details* pDetails) { |
506 | tU32 PDNetExtractGameID(tNet_game_details* pDetails) { |
497 | LOG_TRACE("(%p)", pDetails); |
507 | LOG_TRACE("(%p)", pDetails); |
498 | 508 | ||
499 | dr_dprintf("PDNetExtractGameID()"); |
509 | dr_dprintf("PDNetExtractGameID()"); |
500 | return ntohs(pDetails->pd_net_info.addr_in.sin_port); // PDGetTotalTime(); |
510 | return ntohs(pDetails->pd_net_info.addr_in.sin_port); // PDGetTotalTime(); |
501 | } |
511 | } |
502 | 512 | ||
Line 638... | Line 648... | ||
638 | int PDNetSendMessageToAddress(tNet_game_details* pDetails, tNet_message* pMessage, void* pAddress) { |
648 | int PDNetSendMessageToAddress(tNet_game_details* pDetails, tNet_message* pMessage, void* pAddress) { |
639 | char str[256]; |
649 | char str[256]; |
640 | LOG_TRACE("(%p, %p, %p)", pDetails, pMessage, pAddress); |
650 | LOG_TRACE("(%p, %p, %p)", pDetails, pMessage, pAddress); |
641 | 651 | ||
642 | NetNowIPXLocalTarget2String(str, (struct sockaddr_in*)pAddress); |
652 | NetNowIPXLocalTarget2String(str, (struct sockaddr_in*)pAddress); |
643 | if (pDetails->pd_net_info.addr_in.sin_port == 0) { |
- | |
644 | int i = 0; |
- | |
645 | } |
- | |
646 | 653 | ||
647 | if (sendto(gSocket, (const char*)pMessage, pMessage->overall_size, 0, (const struct sockaddr*)pAddress, sizeof(struct sockaddr)) == -1) { |
654 | if (sendto(gSocket, (const char*)pMessage, pMessage->overall_size, 0, (const struct sockaddr*)pAddress, sizeof(struct sockaddr)) == -1) { |
648 | dr_dprintf("PDNetSendMessageToAddress(): Error on sendto() - WSAGetLastError=%d", WSAGetLastError()); |
655 | dr_dprintf("PDNetSendMessageToAddress(): Error on sendto() - WSAGetLastError=%d", WSAGetLastError()); |
649 | NetDisposeMessage(pDetails, pMessage); |
656 | NetDisposeMessage(pDetails, pMessage); |
650 | return 1; |
657 | return 1; |