This is not about the performance but it does look a lot tidier.
Printable View
This is not about the performance but it does look a lot tidier.
Beauty is in the eye of the beholder. This is an issue of properly documenting the engine function and how you're interfacing with it. Not using inline assembly allows the compiler to add instructions of it's own. It is really unwise to mix asm blocks with C code. You leave the compiler to do pretty much whatever it wants to the resulting output asm. It's why I write explicit function wrappers in OS, and use __declspec(naked) where appropriate.
e: When interfacing with blackbox software which has no code documentation, it is far better to be explicit in your source, especially if others are suppose to look at it and/or grok what is going on.
Okay, thx the help, i'll try to put this new sv_say function like u said when i'm back from the uni. I don't need the chat cuz it works perfectly, Termy made a great job =)
Patrick; u meant call like this;
#define FUNC_ADDPACKETTOPQUEUE 0x004cc700
int ( __cdecl *Say)(int player_index, const char *msg);
Say = ( int(__cdecl*)(int, const char*) ) FUNC_ADDPACKETTOPQUEUE;
Say(player_index, "Hello");
?
Ok, that won't work. You need to build the packet before you can add it to the queue. If you look at my code I call BuildPacket and THEN AddPacketToQueue. You should use embedded calls like I did in my example, it works and is stable. The compiler won't mess anything up. All the function calls you need are already in my example. Copy and paste my BuildPacket and AddPacketToPlayerQueue functions. Once you do that and update the addresses all you need to do is change the code that is specific to Phasor to what SAPP uses.
edit: plus, remember the message needs to be utf-16 encoded, so use wchar_t* instead of char*.
OK, i'll try it now. btw. currently msg sending is works both with char* and wchar_t* in sapp.. odd. well nvm .
edit:owww... almost rdy, only need this address: ADDR_SOCKETREADY (def is missing :/) tho i guess u only have dat address in PC, so how can i find it in CE ? lol
edit2; i skipped this since its just a security function which is erase the msg if packet queue is not rdy:
//MOV ECX,DWORD PTR DS:[ADDR_SOCKETREADY]
//cmp ecx, 0
//je NOT_READY_TO_SEND
so now i can comply, but Halo crashes when i call a msg :/
the problem is that idk what to use as "(*itr)->memoryId" / "(*itr)->mem->playerNum", i used the playerindex from the PlayerTable but it seems its not good... is this a memory address wich points to the player's PlayerTable structure or what? O.o
edit3: ok, my test code witch is not working is;
void GlobalMessage(int PlayerIndex)
{
std::wstring msg = (wchar_t*)L"Test";
// Build the chat packet
chatData d;
d.type = 0;
d.player = Server->MachineInfo[PlayerIndex].Address; // Player we're sending it from
d.msg = (wchar_t*)msg.c_str();
BYTE* packetBuffer = new BYTE[4096 + 2*msg.size()];
DWORD retval = BuildPacket(packetBuffer, 0, 0x0F, 0, (LPBYTE)&d, 0, 1, 0);
AddPacketToPlayerQueue(Server->MachineInfo[PlayerIndex].PlayerNumber, packetBuffer, retval, 1, 1, 0, 1, 3);
}
and the addresses i found in 1.09 ce:
#define FUNC_BUILDPACKET 0x004d9830
#define FUNC_ADDPACKETTOQUEUE 0x004cc850
#define FUNC_ADDPACKETTOPQUEUE 0x004cc700
did i missed sth? :/
That's pretty close, the only issue i see is where you set d.Player. You should make that equal to PlayerIndex, not the player's address. So like d.player = PlayerIndex; Also, don't forget to delete packetBuffer when you're done, you don't want a memory leak.
edit: for ADDR_SOCKETREADY do a binary search for: 89 5E 18 89 1E 89 5E 08 89 5E 0C 89 5E 04 and you should end up seeing something like this http://pastebin.com/kusN1kuy
cool thx. btw i tried it with both playerindex and both memory address but neither works :/ and will it send a private server message to the player or a chat message to himself like in gand.?
edit: ok, now i used PlayerIndex in both places and tested it when only i was in the server (so PlayerIndex = PlayerNumber = MachineIndex = 0), also found that address and deleted the packetBuffer but still getting crashes when i call it:/
mb The addresses (1.09 CE) are wrong?
edit2: wooot i found & fixed the bug and now its works, cooool thx again :D
Your current code will send a message to the specific player and it will be of type all chat. If it doesn't work check your addresses are correct.
Its working now thx ^^
So no more network connection lost error, Thx to urbanyoung !
Now i only need to fix that 2 players can't join with the same cd-key :/ patched the exe with Brandinimp's patcher but that doesnt fixed it. I'll try to change a bit the hash after the player joined.
edit: FIXED! Now players with same CD-Key can join!