Hgserver V3.02 - Released

All helbreath developer topics and releases
Post Reply
KLKS
Loyal fan
Posts: 218
Joined: Sun Feb 22, 2004 2:32 pm

Post by KLKS »

version 3.02
~~~~~~~~~~~~
- Added top level exception handler
- Added angel code by Ayres/diuuude
- Added central logging by Hypnotoad
- Fixed buffer overflow and a few potential crash bugs
- Fixed a certain way of zeroing memory structures
- Broken down code into classes
- Created Crusade class for all Crusade related functions
- Created Admin class for all Admin related functions
- Created Party class for all Party related functions
- Created Guild class for all Guild related functions
- Created Apocolypse class for all Apocolypse related functions
- Created Heldenian class for all Heldenian related functions
- Removed DebugDialog
- Removed more korean comments
- Removed most debugging comments in code, should make it faster abit
- Removed useless class TempNPCItem
diuuude
Outpost bitch
Posts: 592
Joined: Wed Dec 28, 2005 11:57 pm

Post by diuuude »

hum... heldenian wasn't added in the sources i released. But anyways it would be a good idea to add Snoopy's Apocalypse code. It was released few weeks ago in server sources submit forum.

I worked on it right before my hd crashed and it wasn't 100% working. I fixed the flags for Gail and the "hire a combattant", then added the new summon monsters (Elf, sorceress, golem...).

I only had the type 2 working :
Type2

    * When the flag inside Heldenian is replaced, the Castle Seize ends.
    * Only guild master is eligible to replace flag inside Heldenian.
    * When the flag was not replaced in a certain time frame (in about 90 minutes), defendant wins..

I think that Type 1 will be harder to code... Good luck KLKS and great work !
<a href='http://www.technohell.net' target='_blank'><b><span style='color:red'>>>> Helbreath Ressources Website Here <<<</span></b></a><br>C++ Sources, Tools, Server Files, Help on Forum, C++ Snippets, Toplist... Updated often, come visit us !
KLKS
Loyal fan
Posts: 218
Joined: Sun Feb 22, 2004 2:32 pm

Post by KLKS »

version 3.02 will introduce a nice exception handler for u guys to submit crash bugs for us to fix. here's how it looks like

diuuude
Outpost bitch
Posts: 592
Joined: Wed Dec 28, 2005 11:57 pm

Post by diuuude »

woooow

you're really doing a great job KLKS ! keep it on !
<a href='http://www.technohell.net' target='_blank'><b><span style='color:red'>>>> Helbreath Ressources Website Here <<<</span></b></a><br>C++ Sources, Tools, Server Files, Help on Forum, C++ Snippets, Toplist... Updated often, come visit us !
Hypnotoad
Member
Posts: 100
Joined: Wed Apr 28, 2004 8:16 pm

Post by Hypnotoad »

Wow KLKS very nice work on that exception handler. HGServer would have to be compiled in debug mode, none of that 900kb hgserver-we want the 1.5meg behometh for it to have the best use though, so the crash addresses can be easily tracked for your behalf. No need to run ollydbg anymore before launching HGServer (was so laggy). I wish i had enough time to work with you all. on this like i just opened the sources some for the last few days, and after talking with binary and wow, i miss doing this. I still havent taken IT 108: Programming Fundementals lol i need to do that for my IT minor, im an accounting major. But yeah i really miss the community.

In wmain's ThreadProc i noticed "if (G_pGame = NULL)", but my lack of education makes me confused sometimes, Like doesnt G_pGame = NULL set g_pGame to null instead of see IF it is null...also i whipped up a simple way to remove all those functions which make log files by making them go in 1, you can eliminate (PutXSocketLogFileList, PutPvPLogFileList, PutHackLogFileList, PutDebugMsgFileList, PutLogEventFileList, PutAdminLogFileList, PutLogFileList). This might help you on your crusade of simplifying HGServer.

i attached my wmain.cpp

Code: Select all

void PutLogFileType(char *cStr, char cType)
{
 FILE * pFile;
 char cBuffer[512];
 SYSTEMTIME SystemTime;

	_mkdir("LogData");
	switch (cType) {
  case 1: pFile = fopen("LogData\\Events.log", "at");  	break; // PutLogFileList
  case 2: pFile = fopen("LogData\\AdminEvents.log", "at");	break; // PutAdminLogFileList
  case 3: pFile = fopen("LogData\\LogEvents.log", "at");  break; // PutLogEventFileList
  case 4: pFile = fopen("LogData\\DebugMsg.log", "at");  break; // PutDebugMsgFileList
  case 5: pFile = fopen("LogData\\HackEvents.log", "at");  break; // PutHackLogFileList
  case 6: pFile = fopen("LogData\\PvPEvents.log", "at");  break; // PutPvPLogFileList
  case 7: pFile = fopen("LogData\\XSocket.log", "at");  break; // PutXSocketLogFileList
  default: pFile = NULL; break;
	}
	if (pFile == NULL) return;
  	ZeroMemory(cBuffer, sizeof(cBuffer));
	GetLocalTime(&SystemTime);
	wsprintf(cBuffer, "(%4d:%2d:%2d:%2d:%2d) - ", SystemTime.wYear, SystemTime.wMonth, SystemTime.wDay, SystemTime.wHour, SystemTime.wMinute);
	strcat(cBuffer, cStr);
	strcat(cBuffer, "\n");
	fwrite(cBuffer, 1, strlen(cBuffer), pFile);
	fclose(pFile);
}
but before implementing this you would need to remove the other logging functions mentioned above in game.cpp, there are a few hundred i did it 2 times in 15 minutes once and then reverted cuz i went to find and replace crazy. Anyway this wmain is almost 3.61s wmain.cpp except for PutLogList, which i dont seem to understand whats going on in the ASM. Also you should remove all the logging to do with PutLogList, because it is like double logging, and is UNneccesary. Any response is appreciated. Anyway ill try to help you guys in my spare time, but yeah you should know im not a very "workaround" person I'll code it like it is coded officially before going out and making it from scratch.

I am amazed at you guys progress on getting the client going. and lol i kinda wana work on the hack prevention, but since 3.51 source is released something has to be done to communicate to the hgserver that the cooresponding client is the correct client for the server. The easiest way is probably to put a message that the hgserver checks to see if it matches and just armedillo the Client. Im not really sure, id love to hear your thoughts about forcing a specific client to a specific hgserver.
<img src='http://www.playah.no-ip.com/images/Hypn ... imated.gif' border='0' alt='user posted image' />
locobans
Outpost Junkie
Posts: 2264
Joined: Tue Jul 13, 2004 3:51 am
Location: Behind You
Contact:

Post by locobans »

wsprintf(G_cTxt, "GM Order(%s): Shutup PC(%s) (%d)Min", m_pClientList[iClientH]->m_cCharName,
m_pClientList->m_cCharName, iTime);
PutAdminLogFileList(G_cTxt);


So this and other functions like these...will be set to
PutLogFileType(G_cTxt, 2);

Meaning the 2 for the type???

Anyways true reason I'm posting is cause Zero worked with me for a while, helphed me in few stuff related to 2.24b sources...

1 of them was fixing the "bugs" empty spots that server reads them like if there was a person or mob on it...what he did, changed the ThreadProc function to this...


unsigned __stdcall  ThreadProc(void *ch)
{
char cTemp[256];
int i = 0;
class CTile* pTile;
while (G_bIsThread == TRUE)
{
  Sleep(10000);
  ZeroMemory(cTemp, 256);

  for (int a = 0; a < DEF_MAXMAPS; a++)
  {
  if (G_pGame->m_pMapList[a] != NULL)
  {
    for (int iy = 0; iy < G_pGame->m_pMapList[a]->m_sSizeY; iy++)
    {
    for (int ix = 0; ix < G_pGame->m_pMapList[a]->m_sSizeX; ix++)
    {
      pTile = (class CTile *)(G_pGame->m_pMapList[a]->m_pTile + ix + iy*G_pGame->m_pMapList[a]->m_sSizeY);
      if ((pTile != NULL) && (pTile->m_sOwner != NULL) && (pTile->m_cOwnerClass == NULL))
      {
      pTile->m_sOwner = NULL;
      }
    }
    }
  }
  }
}

_endthread();
return 0;
}


I'm posting cause as it seems you changed the ThreadProc but this might be useful after all.

~Locobans, cheers.

P.D: Hi Hypno :P
QUOTE (ADDKiD @ Dec 1 2006, 4:01 PM) <br>You guys make me laugh alot, half the shit I say, is bullshit...<br><br><img src='http://img485.imageshack.us/img485/492/banssig1ng.gif' border='0' alt='user posted image' /><br><br><b>I see no changes at all, wake up in the morning and ask myself...<br>Is life worth living? Should I blast myself?</b><br><br><b><a href='http://2paclegacy.com' target='_blank'>2PacLegacy.com</a></b>
Hypnotoad
Member
Posts: 100
Joined: Wed Apr 28, 2004 8:16 pm

Post by Hypnotoad »

So this and other functions like these...will be set to
PutLogFileType(G_cTxt, 2);

Meaning the 2 for the type???
Yes the type would have to be added like that, and the original function would have to be changed to PutLogFileType.
1 of them was fixing the "bugs" empty spots that server reads them like if there was a person or mob on it...what he did, changed the ThreadProc function to this...
I see what you and zero did, does it work? Sometimes there are really mobs in those spots like if u cast pfm on the spot, the mob or character becomes visable, or maybe the map is messed up.

Threadproc might not be the best place to put that code, i think you should move it to ontimer, since it basically is an ontimer function anyway. After 100000 go through every tile and say noone is on it if noone is on it. Maybe after an NPC is killed or a PCs corpse is dissapeared you can just declare that the tile owner is null. This performs a similar task as KLKSs clean function except the client isnt updated in the end.

Plus you can have crashes possibly if ontimer is run and the game server isnt active. Or maybe its that nasty socket error that just counts sometimes after a restart....
<img src='http://www.playah.no-ip.com/images/Hypn ... imated.gif' border='0' alt='user posted image' />
locobans
Outpost Junkie
Posts: 2264
Joined: Tue Jul 13, 2004 3:51 am
Location: Behind You
Contact:

Post by locobans »

Hypnotoad wrote:
So this and other functions like these...will be set to
PutLogFileType(G_cTxt, 2);

Meaning the 2 for the type???
Yes the type would have to be added like that, and the original function would have to be changed to PutLogFileType.
1 of them was fixing the "bugs" empty spots that server reads them like if there was a person or mob on it...what he did, changed the ThreadProc function to this...
I see what you and zero did, does it work? Sometimes there are really mobs in those spots like if u cast pfm on the spot, the mob or character becomes visable, or maybe the map is messed up.

Threadproc might not be the best place to put that code, i think you should move it to ontimer, since it basically is an ontimer function anyway. After 100000 go through every tile and say noone is on it if noone is on it. Maybe after an NPC is killed or a PCs corpse is dissapeared you can just declare that the tile owner is null. This performs a similar task as KLKSs clean function except the client isnt updated in the end.

Plus you can have crashes possibly if ontimer is run and the game server isnt active. Or maybe its that nasty socket error that just counts sometimes after a restart....
It works...in an awesome way...I mean...it removed the "bumps" that were left in 2.24b+ sources and it never crashed HGServer (no server downtime in 2 weeks) so I guess it's working the right way.

Added it there, cause will cause less lag than OnTimer or other functions I guess.
QUOTE (ADDKiD @ Dec 1 2006, 4:01 PM) <br>You guys make me laugh alot, half the shit I say, is bullshit...<br><br><img src='http://img485.imageshack.us/img485/492/banssig1ng.gif' border='0' alt='user posted image' /><br><br><b>I see no changes at all, wake up in the morning and ask myself...<br>Is life worth living? Should I blast myself?</b><br><br><b><a href='http://2paclegacy.com' target='_blank'>2PacLegacy.com</a></b>
Hypnotoad
Member
Posts: 100
Joined: Wed Apr 28, 2004 8:16 pm

Post by Hypnotoad »

Then klks should add this to 3.02 then, that was a major problem I kept getting harrassed about. But my recommendation is that instead of changing ThreadProc, use the one i provided, and just make a new function in Game.cpp and then place a call for it like after ClearTile() or something.

Ps: Hey loco ;)

ill continue my quest of checking all the HGServers .cpp files for errors and changes. But have a 25 page project and presentation due next week :-/
<img src='http://www.playah.no-ip.com/images/Hypn ... imated.gif' border='0' alt='user posted image' />
locobans
Outpost Junkie
Posts: 2264
Joined: Tue Jul 13, 2004 3:51 am
Location: Behind You
Contact:

Post by locobans »

Hypnotoad wrote: Then klks should add this to 3.02 then, that was a major problem I kept getting harrassed about. But my recommendation is that instead of changing ThreadProc, use the one i provided, and just make a new function in Game.cpp and then place a call for it like after ClearTile() or something.

Ps: Hey loco ;)

ill continue my quest of checking all the HGServers .cpp files for errors and changes. But have a 25 page project and presentation due next week :-/
I guess so :P

Darn 25 pages fuck!

Though, thanks I will use your logging function call :) easier :) might even cause less lag :lol:
QUOTE (ADDKiD @ Dec 1 2006, 4:01 PM) <br>You guys make me laugh alot, half the shit I say, is bullshit...<br><br><img src='http://img485.imageshack.us/img485/492/banssig1ng.gif' border='0' alt='user posted image' /><br><br><b>I see no changes at all, wake up in the morning and ask myself...<br>Is life worth living? Should I blast myself?</b><br><br><b><a href='http://2paclegacy.com' target='_blank'>2PacLegacy.com</a></b>
snoopy81
Loyal fan
Posts: 338
Joined: Mon Jul 12, 2004 7:13 pm

Post by snoopy81 »

1 of them was fixing the "bugs" empty spots that server reads them like if there was a person or mob on it...what he did, changed the ThreadProc function to this...
I have been searching for this bug's reason for mounths...
But never thought to remose...the bug's result!

Nice idea....
Just an idea, declare ix & iy as register int....
_\_ _<br> / , \__/ . \ Admin of Equilibrium Project<br> II\ \___ . O<br> III \_/ \ _ / <a href='http://www.equiprojet.com' target='_blank'>http://www.equiprojet.com</a><br> II I¯I
Hypnotoad
Member
Posts: 100
Joined: Wed Apr 28, 2004 8:16 pm

Post by Hypnotoad »

I was translating and comparing XSocket.cpp and they made some changes perhaps to fix crashes/exploits. I havent tested this code but it looks like it is just a simple check and patch to prevent packets to be received without the t HGServer resgistering that a packet has been sent. Lets say a hacker sends a message to your hgserver, the message will be dumped to _iRegisterUnsentData. But lets say your HGServer writes a packet, then the message should be recieved and sent to _iSend. Code not tested, but should work theoretically.

Whats new and interesting, but not included, is that 2 new XSocket functions that are there which if triggered, (pressing f3 or something) count how much packets are sent by each HGServer, and writes those packets down into DebugMsg.log.

-----------------------------------------------------------------------------
XSocket Changes:
- in XSocket::XSocket add "m_bWriteMessage = FALSE;"
- add "BOOL m_bWriteMessage;" to xsocket.h

- in XSocket::iSendMsg

Code: Select all

memcpy((char *)(m_pSndBuffer + 3), cData, dwSize);
	if (cKey != NULL) { //Encryption
  for (i = 0; i < dwSize; i++) {
  	m_pSndBuffer[3+i] += (i ^ cKey);
  	m_pSndBuffer[3+i]  = m_pSndBuffer[3+i] ^ (cKey ^ (dwSize - i));
  }
	}
//change starts
	if (m_bWriteMessage == FALSE) {
  iRet = _iRegisterUnsentData(m_pSndBuffer, dwSize + 3);
	}
	else {
  iRet = _iSend(m_pSndBuffer, dwSize + 3, TRUE);
	}
 // change ends
	if (iRet < 0) return iRet;
	else return (iRet - 3);
}
- in iOnSocketEvent change FD_WRITE to

Code: Select all

	case FD_WRITE:
  m_bWriteMessage = TRUE; // changed
  return _iSendUnsentData();
  break;
<img src='http://www.playah.no-ip.com/images/Hypn ... imated.gif' border='0' alt='user posted image' />
diuuude
Outpost bitch
Posts: 592
Joined: Wed Dec 28, 2005 11:57 pm

Post by diuuude »

snoopy81 wrote:
1 of them was fixing the "bugs" empty spots that server reads them like if there was a person or mob on it...what he did, changed the ThreadProc function to this...
I have been searching for this bug's reason for mounths...
But never thought to remose...the bug's result!

Nice idea....
Just an idea, declare ix & iy as register int....
<span style='color:red'>Msg From Cleroth</span>

Microsoft Visual C++ ignores 'register' while declaring variables. So it's useless to put it...

I think there's a command that forces VC++ to use registers though. On project settings or something like that
<a href='http://www.technohell.net' target='_blank'><b><span style='color:red'>>>> Helbreath Ressources Website Here <<<</span></b></a><br>C++ Sources, Tools, Server Files, Help on Forum, C++ Snippets, Toplist... Updated often, come visit us !
KLKS
Loyal fan
Posts: 218
Joined: Sun Feb 22, 2004 2:32 pm

Post by KLKS »

due to some complications, i didnt manage to add heldenian and apoc
KLKS
Loyal fan
Posts: 218
Joined: Sun Feb 22, 2004 2:32 pm

Post by KLKS »

due to the large change in source, i have not managed to test it properly so i hope you guys will report bugs in, ie what did you do when it crashed and so on.

if you want to submit the crash which hg generates, please include your executable so we can trace it.
Post Reply