generated from Jaysyn/ModuleTemplate
Merged redundant hak files
Merged redundant hak files. Moved hak scripts into module. Updated gitignore. Full Compile. Added release folder & archive.
This commit is contained in:
251
_mod/_module/nss/rtsa_headers.nss
Normal file
251
_mod/_module/nss/rtsa_headers.nss
Normal file
@@ -0,0 +1,251 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// REAL TIME STRATEGY ADVENTURE - Kit
|
||||
// FILE: rtsa_headers
|
||||
// NAME: STACK FUNCTIONS AND DATA TYPES
|
||||
// SCRIPTED BY: Deva Bryson Winblood
|
||||
// DATE: 4/16/2003
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
#include "rtsa_headere" // error and debug
|
||||
//////////////////////////////////////////
|
||||
// STACK FUNCTIONS - These stack functions support multiple data types
|
||||
//////////////////////////////////////////
|
||||
// fnInitializeStack(),fnPush(),fnPop<dt>(),fnSizeS(),fnFlushS(),fnReverseS()
|
||||
|
||||
void fnInitializeStack(string sPrefix,int nType=0)
|
||||
{ // Setup stack variable on Controller
|
||||
fnDebug("fnInitializeStack("+sPrefix+","+IntToString(nType)+")");
|
||||
SetLocalInt(OBJECT_SELF,sPrefix+"TOP",0);
|
||||
SetLocalInt(OBJECT_SELF,sPrefix+"TYPE",nType);
|
||||
// Types supported 0 = multi-data 1=string 2=int 3=object 4=float
|
||||
} // fnInitializeStack()
|
||||
|
||||
int fnPush(string sPrefix, string sSt="",int nInt=0,object oOb=OBJECT_INVALID, float fFl=0.0,int nIncrement=TRUE)
|
||||
{ // Push item onto stack return -1 if invalid data type
|
||||
object oMe=OBJECT_SELF;
|
||||
int nTop=GetLocalInt(oMe,sPrefix+"TOP");
|
||||
int nType=GetLocalInt(oMe,sPrefix+"TYPE");
|
||||
int nNewTop=nTop;
|
||||
int nRet=1;
|
||||
fnDebug("fnPush("+sPrefix+",'"+sSt+"',"+IntToString(nInt)+","+GetTag(oOb)+","+FloatToString(fFl)+",INCREMENT:"+IntToString(nIncrement)+")");
|
||||
//SendMessageToPC(GetFirstPC(),"Type of stack:"+IntToString(nType));
|
||||
if (sSt!=""&&(nType!=0&&nType!=1)){
|
||||
fnDebug("Strings not allowed on stack");
|
||||
return -1;
|
||||
}
|
||||
if (nInt!=0&&(nType!=0&&nType!=2)) {
|
||||
fnDebug("Integer not allowed on stack");
|
||||
return -1;
|
||||
}
|
||||
if (oOb!=OBJECT_INVALID&&(nType!=0&&nType!=3)){
|
||||
fnDebug("Objects not allowed on stack");
|
||||
return -1;
|
||||
}
|
||||
if (fFl!=0.0&&(nType!=0&&nType!=4)){
|
||||
fnDebug("Floating Point not allowed on stack");
|
||||
return -1;
|
||||
}
|
||||
//SendMessageToPC(GetFirstPC(),"Stack types not invalid");
|
||||
if (sSt!=""||nType==1)
|
||||
{
|
||||
fnDebug(" STRING TYPE");
|
||||
if (nIncrement==TRUE) nNewTop=nTop+1;
|
||||
SetLocalString(oMe,sPrefix+"STR"+IntToString(nNewTop),sSt);
|
||||
}
|
||||
if (nInt!=0||nType==2)
|
||||
{
|
||||
fnDebug(" INTEGER TYPE");
|
||||
if (nIncrement==TRUE) nNewTop=nTop+1;
|
||||
SetLocalInt(oMe,sPrefix+"INT"+IntToString(nNewTop),nInt);
|
||||
}
|
||||
if (oOb!=OBJECT_INVALID||nType==3)
|
||||
{
|
||||
fnDebug(" OBJECT TYPE:"+GetName(oOb)+"/"+GetTag(oOb)+"/"+GetResRef(oOb));
|
||||
if (nIncrement==TRUE) nNewTop=nTop+1;
|
||||
SetLocalObject(oMe,sPrefix+"OB"+IntToString(nNewTop),oOb);
|
||||
}
|
||||
if (fFl!=0.0||nType==4)
|
||||
{
|
||||
fnDebug(" FLOAT TYPE");
|
||||
if (nIncrement==TRUE) nNewTop=nTop+1;
|
||||
SetLocalFloat(oMe,sPrefix+"FL"+IntToString(nNewTop),fFl);
|
||||
}
|
||||
SetLocalInt(oMe,sPrefix+"TOP",nNewTop);
|
||||
//SendMessageToPC(GetFirstPC(),"fnPush() Top="+IntToString(nNewTop));
|
||||
fnDebug(" EXIT PUSH");
|
||||
return nRet;
|
||||
} // fnPush()
|
||||
|
||||
string fnPopString(string sPrefix,int nDecrement=TRUE)
|
||||
{ // pop a string off the stack
|
||||
string sRet="";
|
||||
object oMe=OBJECT_SELF;
|
||||
int nTop=GetLocalInt(oMe,sPrefix+"TOP");
|
||||
fnDebug(" POP STRING");
|
||||
sRet=GetLocalString(oMe,sPrefix+"STR"+IntToString(nTop));
|
||||
if (nDecrement==TRUE)
|
||||
{ // decrement stack
|
||||
DeleteLocalString(oMe,sPrefix+"STR"+IntToString(nTop));
|
||||
DeleteLocalInt(oMe,sPrefix+"INT"+IntToString(nTop));
|
||||
DeleteLocalObject(oMe,sPrefix+"OB"+IntToString(nTop));
|
||||
DeleteLocalFloat(oMe,sPrefix+"FL"+IntToString(nTop));
|
||||
SetLocalInt(oMe,sPrefix+"TOP",nTop-1);
|
||||
} // decrement stack
|
||||
return sRet;
|
||||
} // fnPopString()
|
||||
|
||||
int fnPopInt(string sPrefix,int nDecrement=TRUE)
|
||||
{ // pop an integer off the stack
|
||||
int nRet=0;
|
||||
object oMe=OBJECT_SELF;
|
||||
int nTop=GetLocalInt(oMe,sPrefix+"TOP");
|
||||
fnDebug(" POP INT");
|
||||
nRet=GetLocalInt(oMe,sPrefix+"INT"+IntToString(nTop));
|
||||
if (nDecrement==TRUE)
|
||||
{ // decrement stack
|
||||
DeleteLocalString(oMe,sPrefix+"STR"+IntToString(nTop));
|
||||
DeleteLocalInt(oMe,sPrefix+"INT"+IntToString(nTop));
|
||||
DeleteLocalObject(oMe,sPrefix+"OB"+IntToString(nTop));
|
||||
DeleteLocalFloat(oMe,sPrefix+"FL"+IntToString(nTop));
|
||||
SetLocalInt(oMe,sPrefix+"TOP",nTop-1);
|
||||
} // decrement stack
|
||||
return nRet;
|
||||
} // fnPopInt()
|
||||
|
||||
object fnPopObject(string sPrefix,int nDecrement=TRUE)
|
||||
{ // pop an object off the stack
|
||||
object oRet=OBJECT_INVALID;
|
||||
object oMe=OBJECT_SELF;
|
||||
int nTop=GetLocalInt(oMe,sPrefix+"TOP");
|
||||
fnDebug(" POP OBJECT");
|
||||
oRet=GetLocalObject(oMe,sPrefix+"OB"+IntToString(nTop));
|
||||
if (nDecrement==TRUE)
|
||||
{ // decrement stack
|
||||
DeleteLocalString(oMe,sPrefix+"STR"+IntToString(nTop));
|
||||
DeleteLocalInt(oMe,sPrefix+"INT"+IntToString(nTop));
|
||||
DeleteLocalObject(oMe,sPrefix+"OB"+IntToString(nTop));
|
||||
DeleteLocalFloat(oMe,sPrefix+"FL"+IntToString(nTop));
|
||||
SetLocalInt(oMe,sPrefix+"TOP",nTop-1);
|
||||
} // decrement stack
|
||||
return oRet;
|
||||
} // fnPopObject()
|
||||
|
||||
float fnPopFloat(string sPrefix,int nDecrement=TRUE)
|
||||
{ // pop a float off the stack
|
||||
float fRet=0.0;
|
||||
object oMe=OBJECT_SELF;
|
||||
int nTop=GetLocalInt(oMe,sPrefix+"TOP");
|
||||
fnDebug(" POP FLOAT");
|
||||
fRet=GetLocalFloat(oMe,sPrefix+"FL"+IntToString(nTop));
|
||||
if (nDecrement==TRUE)
|
||||
{ // decrement stack
|
||||
DeleteLocalString(oMe,sPrefix+"STR"+IntToString(nTop));
|
||||
DeleteLocalInt(oMe,sPrefix+"INT"+IntToString(nTop));
|
||||
DeleteLocalObject(oMe,sPrefix+"OB"+IntToString(nTop));
|
||||
DeleteLocalFloat(oMe,sPrefix+"FL"+IntToString(nTop));
|
||||
SetLocalInt(oMe,sPrefix+"TOP",nTop-1);
|
||||
} // decrement stack
|
||||
return fRet;
|
||||
} // fnPopFloat()
|
||||
|
||||
int fnSizeS(string sPrefix)
|
||||
{ // returns TOP of stack #
|
||||
return GetLocalInt(OBJECT_SELF,sPrefix+"TOP");
|
||||
} // fnSizeS()
|
||||
|
||||
void fnFlushS(string sPrefix)
|
||||
{ // Flush the stack
|
||||
string sVal;
|
||||
int nTop=fnSizeS(sPrefix);
|
||||
fnDebug(" fnFlushS("+sPrefix+")");
|
||||
while(nTop!=0)
|
||||
{ // flush stack
|
||||
sVal=fnPopString(sPrefix);
|
||||
nTop=fnSizeS(sPrefix);
|
||||
} // flush stack
|
||||
} // fnFlushS()
|
||||
|
||||
void fnReverseS(string sPrefix)
|
||||
{ // Reverse stack order
|
||||
string sReverse=sPrefix+"R";
|
||||
object oMe=OBJECT_SELF;
|
||||
int nTop=fnSizeS(sPrefix);
|
||||
int nType=GetLocalInt(oMe,sPrefix+"TYPE");
|
||||
string sStr;
|
||||
int nInt;
|
||||
object oOb;
|
||||
float fFl;
|
||||
int nRP;
|
||||
fnInitializeStack(sReverse,0);
|
||||
SetLocalInt(oMe,sReverse+"TOP",nTop);
|
||||
while(nTop>0)
|
||||
{ // reverse stack
|
||||
if (nType==0)
|
||||
{ // multi-type
|
||||
sStr=fnPopString(sPrefix,FALSE);
|
||||
nInt=fnPopInt(sPrefix,FALSE);
|
||||
oOb=fnPopObject(sPrefix,FALSE);
|
||||
fFl=fnPopFloat(sPrefix);
|
||||
fnPush(sReverse,sStr,nInt,oOb,fFl);
|
||||
} // multi-type
|
||||
else if (nType==1)
|
||||
{ // string
|
||||
sStr=fnPopString(sPrefix);
|
||||
fnPush(sReverse,sStr);
|
||||
} // string
|
||||
else if (nType==2)
|
||||
{ // int
|
||||
nInt=fnPopInt(sPrefix);
|
||||
fnPush(sReverse,"",nInt);
|
||||
} // int
|
||||
else if (nType==3)
|
||||
{ // object
|
||||
oOb=fnPopObject(sPrefix);
|
||||
fnPush(sReverse,"",0,oOb);
|
||||
} // object
|
||||
else if (nType==4)
|
||||
{ // float
|
||||
fFl=fnPopFloat(sPrefix);
|
||||
fnPush(sReverse,"",0,OBJECT_INVALID,fFl);
|
||||
} // float
|
||||
nTop=fnSizeS(sPrefix);
|
||||
} // reverse stack
|
||||
nTop=fnSizeS(sReverse);
|
||||
nRP=nTop;
|
||||
while(nTop>0)
|
||||
{ // copy stack
|
||||
if (nType==0)
|
||||
{ // multi-type
|
||||
sStr=fnPopString(sPrefix,FALSE);
|
||||
SetLocalString(oMe,sReverse+"STR"+IntToString(nTop),sStr);
|
||||
nInt=fnPopInt(sPrefix,FALSE);
|
||||
SetLocalInt(oMe,sReverse+"INT"+IntToString(nTop),nInt);
|
||||
oOb=fnPopObject(sPrefix,FALSE);
|
||||
SetLocalObject(oMe,sReverse+"OB"+IntToString(nTop),oOb);
|
||||
fFl=fnPopFloat(sPrefix);
|
||||
SetLocalFloat(oMe,sReverse+"FL"+IntToString(nTop),fFl);
|
||||
} // multi-type
|
||||
else if (nType==1)
|
||||
{ // string
|
||||
sStr=fnPopString(sPrefix);
|
||||
SetLocalString(oMe,sReverse+"STR"+IntToString(nTop),sStr);
|
||||
} // string
|
||||
else if (nType==2)
|
||||
{ // int
|
||||
nInt=fnPopInt(sPrefix);
|
||||
SetLocalInt(oMe,sReverse+"INT"+IntToString(nTop),nInt);
|
||||
} // int
|
||||
else if (nType==3)
|
||||
{ // object
|
||||
oOb=fnPopObject(sPrefix);
|
||||
SetLocalObject(oMe,sReverse+"OB"+IntToString(nTop),oOb);
|
||||
} // object
|
||||
else if (nType==4)
|
||||
{ // float
|
||||
fFl=fnPopFloat(sPrefix);
|
||||
SetLocalFloat(oMe,sReverse+"FL"+IntToString(nTop),fFl);
|
||||
} // float
|
||||
nTop=fnSizeS(sReverse);
|
||||
} // copy stack
|
||||
SetLocalInt(oMe,sPrefix+"TOP",nRP);
|
||||
} // fnReverseS()
|
||||
|
||||
Reference in New Issue
Block a user