I think the long passed into the argument above is mismatched for the "%i" integer type. It means the sprintf function will load four bytes of an eight byte number into the substitution argument.
The code below represents a slight improvement in speed and consolidation, it prints both required variables to produce the name string in one pass.
I believe that it is impossible to name an actor with a long enough tag to overflow the 50 character buffer, as well.
I pass the Actor pointer back instead of the reference, so remember use the "->" to get values from it as opposed to the "." for values.
Also remember if you go to get the name of the Actor passed back, "actor->name" is the name
without the clone number postfix, you have to use "actor->clonename" to get the full qualified name of the actor involved for passing to functions that take a string argument for the actor's name. (and most do)
Hope this helps someone.
- Code: Select all
Actor *g_GetCloneByIndex(const char *cname, int cindex)
{
char buffer[50];
sprintf(buffer,"%s.%i",cname,cindex);
return(getclone(buffer));
}
Cross Platform executable generation in a 4GL C-Scripted Compiler? I've got your Game Maker hanging right here.