View Single Post
Re: PB crashes after typing "meta unload podbot"
Old
  (#11)
Immortal_BLG
Member
 
Status: Offline
Posts: 170
Join Date: Nov 2007
Location: Russian Federation
Default Re: PB crashes after typing "meta unload podbot" - 13-03-2012

Quote:
Originally Posted by KWo
Why exactly in ServerActivate - there is no need to allocate the memory for the string?
because the function "ServerActivate" is called each time at changelevel that lead to multiple memory allocation for strings, but the function "GameInit" is called only ONCE - and this is what you need.

[EDIT]
Excuse silly me....

I have forgotten that really it is impossible to call function "ALLOC_STRING" before the server wasn't loaded...
So fix is:
Remove code:
Code:
for (unsigned char stringIndex (0u); stringIndex < String_Total; ++stringIndex)
	strings[stringIndex] = const_cast <char *> (STRING (ALLOC_STRING (strings[stringIndex])));
from GameDLLInit and put in to:
Code:
int Spawn (edict_t *pent)
{
	{
		static bool isFirstCall (true);

		if (isFirstCall)
		{
			isFirstCall = false;

			for (unsigned char stringIndex (0u); stringIndex < String_Total; ++stringIndex)
				strings[stringIndex] = const_cast <char *> (STRING (ALLOC_STRING (strings[stringIndex])));
		}
	}
	// ...
}
[/EDIT]

Last edited by Immortal_BLG; 13-03-2012 at 05:26..
  
Reply With Quote