View Single Post
Re: PB crashes after typing "meta unload podbot"
Old
  (#8)
KWo
Developer of PODBot mm
 
KWo's Avatar
 
Status: Offline
Posts: 3,425
Join Date: Apr 2004
Default Re: PB crashes after typing "meta unload podbot" - 11-03-2012

Quote:
Originally Posted by KWo View Post
If I have already allocated a memory area for precached model, what should I use in SET_MODEL function then? I don't think I need to allocate the memory the second time for the model name... I believe I should store somewhere the pointer to that area of precached model, then I should use this pointer somehow in SET_MODEL function.
I think You didn't get what I'm asking for... I was refering to the example with precached lgtning.spr here:
dll.cpp
286: m_spriteTexture = PRECACHE_MODEL ("sprites/lgtning.spr");
then m_spriteTexture (which - I believe - it's a pointer to the model name string) is used i.e. in util.cpp:
1755: WRITE_SHORT (m_spriteTexture);
So - the question was:
a) should SET_MODEL function should be used the same way - with stored pointer:
now in dll.cpp:
291: SET_MODEL (pent, "models/player/urban/urban.mdl");
but maybe - if I want to use this model name couple of times in code - it should be:
m_model_urban = PRECACHE_MODEL(const_cast<char *>(STRING (ALLOC_STRING ("models/player/urban/urban.mdl"))));
SET_MODEL (pent, m_model_urban);
b) if the model in example a) doesn't need to be precached, because it was already precached somewhere, how the function SET_MODEL should look like?
c) if I want to use the model name once to set - should the example look like:
SET_MODEL(const_cast<char *>(STRING (ALLOC_STRING ("models/player/urban/urban.mdl"))))?

For me it's more clear if I can see 2 lines of working examples than somebody writes me 1 page of the theory which I cannot get if I cannot see the result how does it work like.
I mean please write 1 example for each function types You were refering to (in the first post) they need to be changed. I mean 1 example how it should look like each SET_MODEL function, 1 example how it should look like MAKE_STRING etc - with eventually something which needs to be added before (like storing a pointer or something or precaching a string and so on). I know this is a pre-school of C++, but as I said - I know how to make the logic to make some working (and even really complicated) code, but I have lack of C++ basic knowledge, so anything new for me makes me troubles if I don't see the working example.
Thanks to everybody for helping and understanding.

[EDIT]
Finally I did all those ALLOC_STRING for proposed SET_MODEL, PRECACHE_* and MAKE_STRING functions and meta unload finally doesn't crash the server, but there are additionally questions:
a) how to use the pointer to precached model mechgibs in dll.cpp - end of ServerActivate function:
1824: PRECACHE_MODEL((char *)STRING (ALLOC_STRING ("models/mechgibs.mdl")))
later in the code in StartFrame function:
1968: SET_MODEL (pClient->pIllumEnt, (char *)STRING (ALLOC_STRING ("models/mechgibs.mdl")));
I mean - if that second ALLOC_STRING leads or doesn't lead to memory leak because of allocating the memory for the same string couple of times - I can feel here some problem.
b) after succesful unloading podbot_mm.dll all slots used by bots still are in use (also You can see not moving bots on the server - like clients away from the keyboard - how to remove them automatically while using meta unload command?
[/EDIT]

Last edited by KWo; 11-03-2012 at 21:27..
  
Reply With Quote