Re: Current 4.1 SSGM bugs/mistakes [message #489312 is a reply to message #489308] |
Thu, 18 September 2014 00:30 |
|
Xpert
Messages: 1588 Registered: December 2005 Location: New York City
Karma:
|
General (1 Star) |
|
|
Just remembered a few more.
Get_Part_Names and Get_Part_Name has a crash issue with the way it's currently written.
it's currently coded:
Toggle Spoiler
int SCRIPTS_API Get_Part_Names(const char *name1)
{
SLNode<SoldierGameObj> *x = GameObjManager::StarGameObjList.Head();
int count = 0;
while (x)
{
GameObject *o = x->Data();
if (o)
{
const char *name = Get_Player_Name(o);
if (stristr(name,name1))
{
count++;
}
delete[] name;
}
x = x->Next();
}
return count;
}
GameObject SCRIPTS_API *Get_Part_Name(const char *name1)
{
SLNode<SoldierGameObj> *x = GameObjManager::StarGameObjList.Head();
int count = 0;
GameObject *current = 0;
while (x)
{
GameObject *o = x->Data();
if (o)
{
const char *name = Get_Player_Name(o);
if (stristr(name,name1))
{
current = o;
count++;
}
delete[] name;
}
x = x->Next();
}
if ((count == 1) && (current) && (Commands->Get_ID(current)))
{
return current;
}
else
{
return 0;
}
}
A fixed one that a lot of plugins including myself use would be:
Toggle Spoiler
GameObject SCRIPTS_API *Get_Part_Name(const char *name1)
{
SLNode<SmartGameObj> *x = GameObjManager::SmartGameObjList.Head();
int count = 0;
GameObject *current = 0;
while (x)
{
GameObject *o = (GameObject *)x->Data();
if (o && Commands->Is_A_Star(o))
{
const char *name = Get_Player_Name(o);
if (stristr(name,name1))
{
current = o;
count++;
}
delete[] name;
}
x = x->Next();
}
if ((count == 1) && (current) && (Commands->Get_ID(current)))
{
return current;
}
else
{
return 0;
}
}
int SCRIPTS_API Get_Part_Names(const char *name1)
{
SLNode<SmartGameObj> *x = GameObjManager::SmartGameObjList.Head();
int count = 0;
while (x)
{
GameObject *o = (GameObject *)x->Data();
if (o && Commands->Is_A_Star(o))
{
const char *name = Get_Player_Name(o);
if (stristr(name,name1))
{
count++;
}
delete[] name;
}
x = x->Next();
}
return count;
}
Creator of NetGuard, an IRC network regulator.
Developer of the CloudyServ 0.982-X project.
Developer of the CloudyServ Ren-X bot.
Part time streamer - https://twitch.tv/gg_wonder
|
|
|