mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-10 23:02:08 +00:00
Merge branch 'master' of https://github.com/rheit/zdoom
This commit is contained in:
commit
a1dfdf0fc7
10 changed files with 440 additions and 133 deletions
|
@ -906,6 +906,7 @@ public:
|
|||
fixed_t wallbouncefactor; // The bounce factor for walls can be different.
|
||||
int bouncecount; // Strife's grenades only bounce twice before exploding
|
||||
fixed_t gravity; // [GRB] Gravity factor
|
||||
fixed_t Friction;
|
||||
int FastChaseStrafeCount;
|
||||
fixed_t pushfactor;
|
||||
int lastpush;
|
||||
|
|
428
src/p_acs.cpp
428
src/p_acs.cpp
|
@ -122,10 +122,11 @@ FRandom pr_acs ("ACS");
|
|||
|
||||
struct CallReturn
|
||||
{
|
||||
CallReturn(int pc, ScriptFunction *func, FBehavior *module, SDWORD *locals, bool discard, unsigned int runaway)
|
||||
CallReturn(int pc, ScriptFunction *func, FBehavior *module, SDWORD *locals, ACSLocalArrays *arrays, bool discard, unsigned int runaway)
|
||||
: ReturnFunction(func),
|
||||
ReturnModule(module),
|
||||
ReturnLocals(locals),
|
||||
ReturnArrays(arrays),
|
||||
ReturnAddress(pc),
|
||||
bDiscardResult(discard),
|
||||
EntryInstrCount(runaway)
|
||||
|
@ -134,6 +135,7 @@ struct CallReturn
|
|||
ScriptFunction *ReturnFunction;
|
||||
FBehavior *ReturnModule;
|
||||
SDWORD *ReturnLocals;
|
||||
ACSLocalArrays *ReturnArrays;
|
||||
int ReturnAddress;
|
||||
int bDiscardResult;
|
||||
unsigned int EntryInstrCount;
|
||||
|
@ -1673,6 +1675,26 @@ void FBehavior::SerializeVarSet (FArchive &arc, SDWORD *vars, int max)
|
|||
}
|
||||
}
|
||||
|
||||
static int ParseLocalArrayChunk(void *chunk, ACSLocalArrays *arrays, int offset)
|
||||
{
|
||||
unsigned count = (LittleShort(((unsigned *)chunk)[1]) - 2) / 4;
|
||||
int *sizes = (int *)((BYTE *)chunk + 10);
|
||||
arrays->Count = count;
|
||||
if (count > 0)
|
||||
{
|
||||
ACSLocalArrayInfo *info = new ACSLocalArrayInfo[count];
|
||||
arrays->Info = info;
|
||||
for (unsigned i = 0; i < count; ++i)
|
||||
{
|
||||
info[i].Size = LittleLong(sizes[i]);
|
||||
info[i].Offset = offset;
|
||||
offset += info[i].Size;
|
||||
}
|
||||
}
|
||||
// Return the new local variable size, with space for the arrays
|
||||
return offset;
|
||||
}
|
||||
|
||||
FBehavior::FBehavior (int lumpnum, FileReader * fr, int len)
|
||||
{
|
||||
BYTE *object;
|
||||
|
@ -1822,12 +1844,45 @@ FBehavior::FBehavior (int lumpnum, FileReader * fr, int len)
|
|||
{
|
||||
DWORD *chunk;
|
||||
|
||||
Functions = FindChunk (MAKE_ID('F','U','N','C'));
|
||||
if (Functions != NULL)
|
||||
// Load functions
|
||||
BYTE *funcs;
|
||||
Functions = NULL;
|
||||
funcs = FindChunk (MAKE_ID('F','U','N','C'));
|
||||
if (funcs != NULL)
|
||||
{
|
||||
NumFunctions = LittleLong(((DWORD *)Functions)[1]) / 8;
|
||||
Functions += 8;
|
||||
NumFunctions = LittleLong(((DWORD *)funcs)[1]) / 8;
|
||||
funcs += 8;
|
||||
FunctionProfileData = new ACSProfileInfo[NumFunctions];
|
||||
Functions = new ScriptFunction[NumFunctions];
|
||||
for (i = 0; i < NumFunctions; ++i)
|
||||
{
|
||||
ScriptFunctionInFile *funcf = &((ScriptFunctionInFile *)funcs)[i];
|
||||
ScriptFunction *funcm = &Functions[i];
|
||||
funcm->ArgCount = funcf->ArgCount;
|
||||
funcm->HasReturnValue = funcf->HasReturnValue;
|
||||
funcm->ImportNum = funcf->ImportNum;
|
||||
funcm->LocalCount = funcf->LocalCount;
|
||||
funcm->Address = funcf->Address;
|
||||
}
|
||||
}
|
||||
|
||||
// Load local arrays for functions
|
||||
if (NumFunctions > 0)
|
||||
{
|
||||
for (chunk = (DWORD *)FindChunk(MAKE_ID('F','A','R','Y')); chunk != NULL; chunk = (DWORD *)NextChunk((BYTE *)chunk))
|
||||
{
|
||||
int size = LittleLong(chunk[1]);
|
||||
if (size >= 6)
|
||||
{
|
||||
unsigned int func_num = LittleShort(((WORD *)chunk)[4]);
|
||||
if (func_num < (unsigned int)NumFunctions)
|
||||
{
|
||||
ScriptFunction *func = &Functions[func_num];
|
||||
// Unlike scripts, functions do not include their arg count in their local count.
|
||||
func->LocalCount = ParseLocalArrayChunk(chunk, &func->LocalArrays, func->LocalCount + func->ArgCount) - func->ArgCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Load JUMP points
|
||||
|
@ -2135,6 +2190,11 @@ FBehavior::~FBehavior ()
|
|||
delete[] ArrayStore;
|
||||
ArrayStore = NULL;
|
||||
}
|
||||
if (Functions != NULL)
|
||||
{
|
||||
delete[] Functions;
|
||||
Functions = NULL;
|
||||
}
|
||||
if (FunctionProfileData != NULL)
|
||||
{
|
||||
delete[] FunctionProfileData;
|
||||
|
@ -2302,6 +2362,21 @@ void FBehavior::LoadScriptsDirectory ()
|
|||
}
|
||||
}
|
||||
|
||||
// Load script array sizes. (One chunk per script that uses arrays.)
|
||||
for (scripts.b = FindChunk(MAKE_ID('S','A','R','Y')); scripts.dw != NULL; scripts.b = NextChunk(scripts.b))
|
||||
{
|
||||
int size = LittleLong(scripts.dw[1]);
|
||||
if (size >= 6)
|
||||
{
|
||||
int script_num = LittleShort(scripts.w[4]);
|
||||
ScriptPtr *ptr = const_cast<ScriptPtr *>(FindScript(script_num));
|
||||
if (ptr != NULL)
|
||||
{
|
||||
ptr->VarCount = ParseLocalArrayChunk(scripts.b, &ptr->LocalArrays, ptr->VarCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Load script names (if any)
|
||||
scripts.b = FindChunk(MAKE_ID('S','N','A','M'));
|
||||
if (scripts.dw != NULL)
|
||||
|
@ -3530,7 +3605,8 @@ enum
|
|||
APROP_MeleeRange = 38,
|
||||
APROP_ViewHeight = 39,
|
||||
APROP_AttackZOffset = 40,
|
||||
APROP_StencilColor = 41
|
||||
APROP_StencilColor = 41,
|
||||
APROP_Friction = 42,
|
||||
};
|
||||
|
||||
// These are needed for ACS's APROP_RenderStyle
|
||||
|
@ -3764,6 +3840,9 @@ void DLevelScript::DoSetActorProperty (AActor *actor, int property, int value)
|
|||
actor->SetShade(value);
|
||||
break;
|
||||
|
||||
case APROP_Friction:
|
||||
actor->Friction = value;
|
||||
|
||||
default:
|
||||
// do nothing.
|
||||
break;
|
||||
|
@ -3862,6 +3941,7 @@ int DLevelScript::GetActorProperty (int tid, int property, const SDWORD *stack,
|
|||
case APROP_Species: return GlobalACSStrings.AddString(actor->GetSpecies(), stack, stackdepth);
|
||||
case APROP_NameTag: return GlobalACSStrings.AddString(actor->GetTag(), stack, stackdepth);
|
||||
case APROP_StencilColor:return actor->fillcolor;
|
||||
case APROP_Friction: return actor->Friction;
|
||||
|
||||
default: return 0;
|
||||
}
|
||||
|
@ -5460,14 +5540,50 @@ inline int getshort (int *&pc)
|
|||
return res;
|
||||
}
|
||||
|
||||
static bool CharArrayParms(int &capacity, int &offset, int &a, int *Stack, int &sp, bool ranged)
|
||||
{
|
||||
if (ranged)
|
||||
{
|
||||
capacity = STACK(1);
|
||||
offset = STACK(2);
|
||||
if (capacity < 1 || offset < 0)
|
||||
{
|
||||
sp -= 4;
|
||||
return false;
|
||||
}
|
||||
sp -= 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
capacity = INT_MAX;
|
||||
offset = 0;
|
||||
}
|
||||
a = STACK(1);
|
||||
offset += STACK(2);
|
||||
sp -= 2;
|
||||
return true;
|
||||
}
|
||||
|
||||
int DLevelScript::RunScript ()
|
||||
{
|
||||
DACSThinker *controller = DACSThinker::ActiveThinker;
|
||||
SDWORD *locals = localvars;
|
||||
ACSLocalArrays noarrays;
|
||||
ACSLocalArrays *localarrays = &noarrays;
|
||||
ScriptFunction *activeFunction = NULL;
|
||||
FRemapTable *translation = 0;
|
||||
int resultValue = 1;
|
||||
|
||||
if (InModuleScriptNumber >= 0)
|
||||
{
|
||||
ScriptPtr *ptr = activeBehavior->GetScriptPtr(InModuleScriptNumber);
|
||||
assert(ptr != NULL);
|
||||
if (ptr != NULL)
|
||||
{
|
||||
localarrays = &ptr->LocalArrays;
|
||||
}
|
||||
}
|
||||
|
||||
// Hexen truncates all special arguments to bytes (only when using an old MAPINFO and old ACS format
|
||||
const int specialargmask = ((level.flags2 & LEVEL2_HEXENHACK) && activeBehavior->GetFormat() == ACS_Old) ? 255 : ~0;
|
||||
|
||||
|
@ -5832,9 +5948,10 @@ int DLevelScript::RunScript ()
|
|||
}
|
||||
sp += i;
|
||||
::new(&Stack[sp]) CallReturn(activeBehavior->PC2Ofs(pc), activeFunction,
|
||||
activeBehavior, mylocals, pcd == PCD_CALLDISCARD, runaway);
|
||||
activeBehavior, mylocals, localarrays, pcd == PCD_CALLDISCARD, runaway);
|
||||
sp += (sizeof(CallReturn) + sizeof(int) - 1) / sizeof(int);
|
||||
pc = module->Ofs2PC (func->Address);
|
||||
localarrays = &func->LocalArrays;
|
||||
activeFunction = func;
|
||||
activeBehavior = module;
|
||||
fmt = module->GetFormat();
|
||||
|
@ -5868,6 +5985,7 @@ int DLevelScript::RunScript ()
|
|||
activeBehavior = ret->ReturnModule;
|
||||
fmt = activeBehavior->GetFormat();
|
||||
locals = ret->ReturnLocals;
|
||||
localarrays = ret->ReturnArrays;
|
||||
if (!ret->bDiscardResult)
|
||||
{
|
||||
Stack[sp++] = value;
|
||||
|
@ -5966,6 +6084,11 @@ int DLevelScript::RunScript ()
|
|||
sp--;
|
||||
break;
|
||||
|
||||
case PCD_ASSIGNSCRIPTARRAY:
|
||||
localarrays->Set(locals, NEXTBYTE, STACK(2), STACK(1));
|
||||
sp -= 2;
|
||||
break;
|
||||
|
||||
case PCD_ASSIGNMAPARRAY:
|
||||
activeBehavior->SetArrayVal (*(activeBehavior->MapVars[NEXTBYTE]), STACK(2), STACK(1));
|
||||
sp -= 2;
|
||||
|
@ -5997,6 +6120,10 @@ int DLevelScript::RunScript ()
|
|||
PushToStack (ACS_GlobalVars[NEXTBYTE]);
|
||||
break;
|
||||
|
||||
case PCD_PUSHSCRIPTARRAY:
|
||||
STACK(1) = localarrays->Get(locals, NEXTBYTE, STACK(1));
|
||||
break;
|
||||
|
||||
case PCD_PUSHMAPARRAY:
|
||||
STACK(1) = activeBehavior->GetArrayVal (*(activeBehavior->MapVars[NEXTBYTE]), STACK(1));
|
||||
break;
|
||||
|
@ -6029,6 +6156,14 @@ int DLevelScript::RunScript ()
|
|||
sp--;
|
||||
break;
|
||||
|
||||
case PCD_ADDSCRIPTARRAY:
|
||||
{
|
||||
int a = NEXTBYTE, i = STACK(2);
|
||||
localarrays->Set(locals, a, i, localarrays->Get(locals, a, i) + STACK(1));
|
||||
sp -= 2;
|
||||
}
|
||||
break;
|
||||
|
||||
case PCD_ADDMAPARRAY:
|
||||
{
|
||||
int a = *(activeBehavior->MapVars[NEXTBYTE]);
|
||||
|
@ -6074,6 +6209,14 @@ int DLevelScript::RunScript ()
|
|||
sp--;
|
||||
break;
|
||||
|
||||
case PCD_SUBSCRIPTARRAY:
|
||||
{
|
||||
int a = NEXTBYTE, i = STACK(2);
|
||||
localarrays->Set(locals, a, i, localarrays->Get(locals, a, i) - STACK(1));
|
||||
sp -= 2;
|
||||
}
|
||||
break;
|
||||
|
||||
case PCD_SUBMAPARRAY:
|
||||
{
|
||||
int a = *(activeBehavior->MapVars[NEXTBYTE]);
|
||||
|
@ -6119,6 +6262,14 @@ int DLevelScript::RunScript ()
|
|||
sp--;
|
||||
break;
|
||||
|
||||
case PCD_MULSCRIPTARRAY:
|
||||
{
|
||||
int a = NEXTBYTE, i = STACK(2);
|
||||
localarrays->Set(locals, a, i, localarrays->Get(locals, a, i) * STACK(1));
|
||||
sp -= 2;
|
||||
}
|
||||
break;
|
||||
|
||||
case PCD_MULMAPARRAY:
|
||||
{
|
||||
int a = *(activeBehavior->MapVars[NEXTBYTE]);
|
||||
|
@ -6192,6 +6343,19 @@ int DLevelScript::RunScript ()
|
|||
}
|
||||
break;
|
||||
|
||||
case PCD_DIVSCRIPTARRAY:
|
||||
if (STACK(1) == 0)
|
||||
{
|
||||
state = SCRIPT_DivideBy0;
|
||||
}
|
||||
else
|
||||
{
|
||||
int a = NEXTBYTE, i = STACK(2);
|
||||
localarrays->Set(locals, a, i, localarrays->Get(locals, a, i) / STACK(1));
|
||||
sp -= 2;
|
||||
}
|
||||
break;
|
||||
|
||||
case PCD_DIVMAPARRAY:
|
||||
if (STACK(1) == 0)
|
||||
{
|
||||
|
@ -6280,6 +6444,19 @@ int DLevelScript::RunScript ()
|
|||
}
|
||||
break;
|
||||
|
||||
case PCD_MODSCRIPTARRAY:
|
||||
if (STACK(1) == 0)
|
||||
{
|
||||
state = SCRIPT_ModulusBy0;
|
||||
}
|
||||
else
|
||||
{
|
||||
int a = NEXTBYTE, i = STACK(2);
|
||||
localarrays->Set(locals, a, i, localarrays->Get(locals, a, i) % STACK(1));
|
||||
sp -= 2;
|
||||
}
|
||||
break;
|
||||
|
||||
case PCD_MODMAPARRAY:
|
||||
if (STACK(1) == 0)
|
||||
{
|
||||
|
@ -6341,6 +6518,14 @@ int DLevelScript::RunScript ()
|
|||
sp--;
|
||||
break;
|
||||
|
||||
case PCD_ANDSCRIPTARRAY:
|
||||
{
|
||||
int a = NEXTBYTE, i = STACK(2);
|
||||
localarrays->Set(locals, a, i, localarrays->Get(locals, a, i) & STACK(1));
|
||||
sp -= 2;
|
||||
}
|
||||
break;
|
||||
|
||||
case PCD_ANDMAPARRAY:
|
||||
{
|
||||
int a = *(activeBehavior->MapVars[NEXTBYTE]);
|
||||
|
@ -6386,6 +6571,14 @@ int DLevelScript::RunScript ()
|
|||
sp--;
|
||||
break;
|
||||
|
||||
case PCD_EORSCRIPTARRAY:
|
||||
{
|
||||
int a = NEXTBYTE, i = STACK(2);
|
||||
localarrays->Set(locals, a, i, localarrays->Get(locals, a, i) ^ STACK(1));
|
||||
sp -= 2;
|
||||
}
|
||||
break;
|
||||
|
||||
case PCD_EORMAPARRAY:
|
||||
{
|
||||
int a = *(activeBehavior->MapVars[NEXTBYTE]);
|
||||
|
@ -6431,6 +6624,14 @@ int DLevelScript::RunScript ()
|
|||
sp--;
|
||||
break;
|
||||
|
||||
case PCD_ORSCRIPTARRAY:
|
||||
{
|
||||
int a = NEXTBYTE, i = STACK(2);
|
||||
localarrays->Set(locals, a, i, localarrays->Get(locals, a, i) | STACK(1));
|
||||
sp -= 2;
|
||||
}
|
||||
break;
|
||||
|
||||
case PCD_ORMAPARRAY:
|
||||
{
|
||||
int a = *(activeBehavior->MapVars[NEXTBYTE]);
|
||||
|
@ -6477,6 +6678,14 @@ int DLevelScript::RunScript ()
|
|||
sp--;
|
||||
break;
|
||||
|
||||
case PCD_LSSCRIPTARRAY:
|
||||
{
|
||||
int a = NEXTBYTE, i = STACK(2);
|
||||
localarrays->Set(locals, a, i, localarrays->Get(locals, a, i) << STACK(1));
|
||||
sp -= 2;
|
||||
}
|
||||
break;
|
||||
|
||||
case PCD_LSMAPARRAY:
|
||||
{
|
||||
int a = *(activeBehavior->MapVars[NEXTBYTE]);
|
||||
|
@ -6522,6 +6731,14 @@ int DLevelScript::RunScript ()
|
|||
sp--;
|
||||
break;
|
||||
|
||||
case PCD_RSSCRIPTARRAY:
|
||||
{
|
||||
int a = NEXTBYTE, i = STACK(2);
|
||||
localarrays->Set(locals, a, i, localarrays->Get(locals, a, i) >> STACK(1));
|
||||
sp -= 2;
|
||||
}
|
||||
break;
|
||||
|
||||
case PCD_RSMAPARRAY:
|
||||
{
|
||||
int a = *(activeBehavior->MapVars[NEXTBYTE]);
|
||||
|
@ -6564,6 +6781,14 @@ int DLevelScript::RunScript ()
|
|||
++ACS_GlobalVars[NEXTBYTE];
|
||||
break;
|
||||
|
||||
case PCD_INCSCRIPTARRAY:
|
||||
{
|
||||
int a = NEXTBYTE, i = STACK(1);
|
||||
localarrays->Set(locals, a, i, localarrays->Get(locals, a, i) + 1);
|
||||
sp--;
|
||||
}
|
||||
break;
|
||||
|
||||
case PCD_INCMAPARRAY:
|
||||
{
|
||||
int a = *(activeBehavior->MapVars[NEXTBYTE]);
|
||||
|
@ -6605,6 +6830,14 @@ int DLevelScript::RunScript ()
|
|||
--ACS_GlobalVars[NEXTBYTE];
|
||||
break;
|
||||
|
||||
case PCD_DECSCRIPTARRAY:
|
||||
{
|
||||
int a = NEXTBYTE, i = STACK(1);
|
||||
localarrays->Set(locals, a, i, localarrays->Get(locals, a, i) - 1);
|
||||
sp--;
|
||||
}
|
||||
break;
|
||||
|
||||
case PCD_DECMAPARRAY:
|
||||
{
|
||||
int a = *(activeBehavior->MapVars[NEXTBYTE]);
|
||||
|
@ -7031,37 +7264,35 @@ scriptwait:
|
|||
}
|
||||
break;
|
||||
|
||||
// Print script character array
|
||||
case PCD_PRINTSCRIPTCHARARRAY:
|
||||
case PCD_PRINTSCRIPTCHRANGE:
|
||||
{
|
||||
int capacity, offset, a, c;
|
||||
if (CharArrayParms(capacity, offset, a, Stack, sp, pcd == PCD_PRINTSCRIPTCHRANGE))
|
||||
{
|
||||
while (capacity-- && (c = localarrays->Get(locals, a, offset)) != '\0')
|
||||
{
|
||||
work += (char)c;
|
||||
offset++;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
// [JB] Print map character array
|
||||
case PCD_PRINTMAPCHARARRAY:
|
||||
case PCD_PRINTMAPCHRANGE:
|
||||
{
|
||||
int capacity, offset;
|
||||
|
||||
if (pcd == PCD_PRINTMAPCHRANGE)
|
||||
int capacity, offset, a, c;
|
||||
if (CharArrayParms(capacity, offset, a, Stack, sp, pcd == PCD_PRINTMAPCHRANGE))
|
||||
{
|
||||
capacity = STACK(1);
|
||||
offset = STACK(2);
|
||||
if (capacity < 1 || offset < 0)
|
||||
while (capacity-- && (c = activeBehavior->GetArrayVal (a, offset)) != '\0')
|
||||
{
|
||||
sp -= 4;
|
||||
break;
|
||||
work += (char)c;
|
||||
offset++;
|
||||
}
|
||||
sp -= 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
capacity = 0x7FFFFFFF;
|
||||
offset = 0;
|
||||
}
|
||||
|
||||
int a = *(activeBehavior->MapVars[STACK(1)]);
|
||||
offset += STACK(2);
|
||||
int c;
|
||||
while(capacity-- && (c = activeBehavior->GetArrayVal (a, offset)) != '\0') {
|
||||
work += (char)c;
|
||||
offset++;
|
||||
}
|
||||
sp-= 2;
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -7069,32 +7300,15 @@ scriptwait:
|
|||
case PCD_PRINTWORLDCHARARRAY:
|
||||
case PCD_PRINTWORLDCHRANGE:
|
||||
{
|
||||
int capacity, offset;
|
||||
if (pcd == PCD_PRINTWORLDCHRANGE)
|
||||
int capacity, offset, a, c;
|
||||
if (CharArrayParms(capacity, offset, a, Stack, sp, pcd == PCD_PRINTWORLDCHRANGE))
|
||||
{
|
||||
capacity = STACK(1);
|
||||
offset = STACK(2);
|
||||
if (capacity < 1 || offset < 0)
|
||||
while (capacity-- && (c = ACS_WorldArrays[a][offset]) != '\0')
|
||||
{
|
||||
sp -= 4;
|
||||
break;
|
||||
work += (char)c;
|
||||
offset++;
|
||||
}
|
||||
sp -= 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
capacity = 0x7FFFFFFF;
|
||||
offset = 0;
|
||||
}
|
||||
|
||||
int a = STACK(1);
|
||||
offset += STACK(2);
|
||||
int c;
|
||||
while(capacity-- && (c = ACS_WorldArrays[a][offset]) != '\0') {
|
||||
work += (char)c;
|
||||
offset++;
|
||||
}
|
||||
sp-= 2;
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -7102,32 +7316,15 @@ scriptwait:
|
|||
case PCD_PRINTGLOBALCHARARRAY:
|
||||
case PCD_PRINTGLOBALCHRANGE:
|
||||
{
|
||||
int capacity, offset;
|
||||
if (pcd == PCD_PRINTGLOBALCHRANGE)
|
||||
int capacity, offset, a, c;
|
||||
if (CharArrayParms(capacity, offset, a, Stack, sp, pcd == PCD_PRINTGLOBALCHRANGE))
|
||||
{
|
||||
capacity = STACK(1);
|
||||
offset = STACK(2);
|
||||
if (capacity < 1 || offset < 0)
|
||||
while (capacity-- && (c = ACS_GlobalArrays[a][offset]) != '\0')
|
||||
{
|
||||
sp -= 4;
|
||||
break;
|
||||
work += (char)c;
|
||||
offset++;
|
||||
}
|
||||
sp -= 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
capacity = 0x7FFFFFFF;
|
||||
offset = 0;
|
||||
}
|
||||
|
||||
int a = STACK(1);
|
||||
offset += STACK(2);
|
||||
int c;
|
||||
while(capacity-- && (c = ACS_GlobalArrays[a][offset]) != '\0') {
|
||||
work += (char)c;
|
||||
offset++;
|
||||
}
|
||||
sp-= 2;
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -8674,6 +8871,7 @@ scriptwait:
|
|||
}
|
||||
break;
|
||||
|
||||
case PCD_STRCPYTOSCRIPTCHRANGE:
|
||||
case PCD_STRCPYTOMAPCHRANGE:
|
||||
case PCD_STRCPYTOWORLDCHRANGE:
|
||||
case PCD_STRCPYTOGLOBALCHRANGE:
|
||||
|
@ -8704,7 +8902,7 @@ scriptwait:
|
|||
break;
|
||||
}
|
||||
|
||||
for (int i = 0;i < STACK(1); i++)
|
||||
for (int i = 0; i < STACK(1); i++)
|
||||
{
|
||||
if (! (*(lookup++)))
|
||||
{
|
||||
|
@ -8715,43 +8913,55 @@ scriptwait:
|
|||
|
||||
switch (pcd)
|
||||
{
|
||||
case PCD_STRCPYTOMAPCHRANGE:
|
||||
{
|
||||
int a = STACK(5);
|
||||
if (a < NUM_MAPVARS && a > 0 &&
|
||||
activeBehavior->MapVars[a])
|
||||
{
|
||||
Stack[sp-6] = activeBehavior->CopyStringToArray(*(activeBehavior->MapVars[a]), index, capacity, lookup);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case PCD_STRCPYTOWORLDCHRANGE:
|
||||
{
|
||||
int a = STACK(5);
|
||||
case PCD_STRCPYTOSCRIPTCHRANGE:
|
||||
{
|
||||
int a = STACK(5);
|
||||
|
||||
while (capacity-- > 0)
|
||||
{
|
||||
ACS_WorldArrays[a][index++] = *lookup;
|
||||
if (! (*(lookup++))) goto STRCPYTORANGECOMPLETE; // complete with terminating 0
|
||||
}
|
||||
|
||||
Stack[sp-6] = !(*lookup); // true/success if only terminating 0 was not copied
|
||||
}
|
||||
break;
|
||||
case PCD_STRCPYTOGLOBALCHRANGE:
|
||||
while (capacity-- > 0)
|
||||
{
|
||||
int a = STACK(5);
|
||||
|
||||
while (capacity-- > 0)
|
||||
{
|
||||
ACS_GlobalArrays[a][index++] = *lookup;
|
||||
if (! (*(lookup++))) goto STRCPYTORANGECOMPLETE; // complete with terminating 0
|
||||
}
|
||||
|
||||
Stack[sp-6] = !(*lookup); // true/success if only terminating 0 was not copied
|
||||
localarrays->Set(locals, a, index++, *lookup);
|
||||
if (! (*(lookup++))) goto STRCPYTORANGECOMPLETE; // complete with terminating 0
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
Stack[sp-6] = !(*lookup); // true/success if only terminating 0 was not copied
|
||||
}
|
||||
break;
|
||||
case PCD_STRCPYTOMAPCHRANGE:
|
||||
{
|
||||
int a = STACK(5);
|
||||
if (a < NUM_MAPVARS && a > 0 &&
|
||||
activeBehavior->MapVars[a])
|
||||
{
|
||||
Stack[sp-6] = activeBehavior->CopyStringToArray(*(activeBehavior->MapVars[a]), index, capacity, lookup);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case PCD_STRCPYTOWORLDCHRANGE:
|
||||
{
|
||||
int a = STACK(5);
|
||||
|
||||
while (capacity-- > 0)
|
||||
{
|
||||
ACS_WorldArrays[a][index++] = *lookup;
|
||||
if (! (*(lookup++))) goto STRCPYTORANGECOMPLETE; // complete with terminating 0
|
||||
}
|
||||
|
||||
Stack[sp-6] = !(*lookup); // true/success if only terminating 0 was not copied
|
||||
}
|
||||
break;
|
||||
case PCD_STRCPYTOGLOBALCHRANGE:
|
||||
{
|
||||
int a = STACK(5);
|
||||
|
||||
while (capacity-- > 0)
|
||||
{
|
||||
ACS_GlobalArrays[a][index++] = *lookup;
|
||||
if (! (*(lookup++))) goto STRCPYTORANGECOMPLETE; // complete with terminating 0
|
||||
}
|
||||
|
||||
Stack[sp-6] = !(*lookup); // true/success if only terminating 0 was not copied
|
||||
}
|
||||
break;
|
||||
}
|
||||
sp -= 5;
|
||||
}
|
||||
|
|
79
src/p_acs.h
79
src/p_acs.h
|
@ -144,6 +144,51 @@ struct ProfileCollector
|
|||
int Index;
|
||||
};
|
||||
|
||||
struct ACSLocalArrayInfo
|
||||
{
|
||||
unsigned int Size;
|
||||
int Offset;
|
||||
};
|
||||
|
||||
struct ACSLocalArrays
|
||||
{
|
||||
unsigned int Count;
|
||||
ACSLocalArrayInfo *Info;
|
||||
|
||||
ACSLocalArrays()
|
||||
{
|
||||
Count = 0;
|
||||
Info = NULL;
|
||||
}
|
||||
~ACSLocalArrays()
|
||||
{
|
||||
if (Info != NULL)
|
||||
{
|
||||
delete[] Info;
|
||||
Info = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
// Bounds-checking Set and Get for local arrays
|
||||
void Set(int *locals, int arraynum, int arrayentry, int value)
|
||||
{
|
||||
if ((unsigned int)arraynum < Count &&
|
||||
(unsigned int)arrayentry < Info[arraynum].Size)
|
||||
{
|
||||
locals[Info[arraynum].Offset + arrayentry] = value;
|
||||
}
|
||||
}
|
||||
int Get(int *locals, int arraynum, int arrayentry)
|
||||
{
|
||||
if ((unsigned int)arraynum < Count &&
|
||||
(unsigned int)arrayentry < Info[arraynum].Size)
|
||||
{
|
||||
return locals[Info[arraynum].Offset + arrayentry];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
// The in-memory version
|
||||
struct ScriptPtr
|
||||
{
|
||||
|
@ -153,6 +198,7 @@ struct ScriptPtr
|
|||
BYTE ArgCount;
|
||||
WORD VarCount;
|
||||
WORD Flags;
|
||||
ACSLocalArrays LocalArrays;
|
||||
|
||||
ACSProfileInfo ProfileData;
|
||||
};
|
||||
|
@ -189,7 +235,7 @@ struct ScriptFlagsPtr
|
|||
WORD Flags;
|
||||
};
|
||||
|
||||
struct ScriptFunction
|
||||
struct ScriptFunctionInFile
|
||||
{
|
||||
BYTE ArgCount;
|
||||
BYTE LocalCount;
|
||||
|
@ -198,6 +244,16 @@ struct ScriptFunction
|
|||
DWORD Address;
|
||||
};
|
||||
|
||||
struct ScriptFunction
|
||||
{
|
||||
BYTE ArgCount;
|
||||
BYTE HasReturnValue;
|
||||
BYTE ImportNum;
|
||||
int LocalCount;
|
||||
DWORD Address;
|
||||
ACSLocalArrays LocalArrays;
|
||||
};
|
||||
|
||||
// Script types
|
||||
enum
|
||||
{
|
||||
|
@ -285,7 +341,7 @@ private:
|
|||
BYTE *Chunks;
|
||||
ScriptPtr *Scripts;
|
||||
int NumScripts;
|
||||
BYTE *Functions;
|
||||
ScriptFunction *Functions;
|
||||
ACSProfileInfo *FunctionProfileData;
|
||||
int NumFunctions;
|
||||
ArrayInfo *ArrayStore;
|
||||
|
@ -694,8 +750,25 @@ public:
|
|||
PCD_SCRIPTWAITNAMED,
|
||||
PCD_TRANSLATIONRANGE3,
|
||||
PCD_GOTOSTACK,
|
||||
PCD_ASSIGNSCRIPTARRAY,
|
||||
PCD_PUSHSCRIPTARRAY,
|
||||
PCD_ADDSCRIPTARRAY,
|
||||
PCD_SUBSCRIPTARRAY,
|
||||
PCD_MULSCRIPTARRAY,
|
||||
PCD_DIVSCRIPTARRAY,
|
||||
/*370*/ PCD_MODSCRIPTARRAY,
|
||||
PCD_INCSCRIPTARRAY,
|
||||
PCD_DECSCRIPTARRAY,
|
||||
PCD_ANDSCRIPTARRAY,
|
||||
PCD_EORSCRIPTARRAY,
|
||||
PCD_ORSCRIPTARRAY,
|
||||
PCD_LSSCRIPTARRAY,
|
||||
PCD_RSSCRIPTARRAY,
|
||||
PCD_PRINTSCRIPTCHARARRAY,
|
||||
PCD_PRINTSCRIPTCHRANGE,
|
||||
/*380*/ PCD_STRCPYTOSCRIPTCHRANGE,
|
||||
|
||||
/*363*/ PCODE_COMMAND_COUNT
|
||||
/*381*/ PCODE_COMMAND_COUNT
|
||||
};
|
||||
|
||||
// Some constants used by ACS scripts
|
||||
|
|
|
@ -554,7 +554,13 @@ int P_GetFriction (const AActor *mo, int *frictionfactor)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (mo->Friction != FRACUNIT)
|
||||
{
|
||||
friction = clamp(FixedMul(friction, mo->Friction), 0, FRACUNIT);
|
||||
movefactor = FrictionToMoveFactor(friction);
|
||||
}
|
||||
|
||||
if (frictionfactor)
|
||||
*frictionfactor = movefactor;
|
||||
|
||||
|
|
|
@ -1990,26 +1990,12 @@ void P_SetSectorFriction (int tag, int amount, bool alterFlag)
|
|||
friction = (0x1EB8*amount)/0x80 + 0xD001;
|
||||
|
||||
// killough 8/28/98: prevent odd situations
|
||||
if (friction > FRACUNIT)
|
||||
friction = FRACUNIT;
|
||||
if (friction < 0)
|
||||
friction = 0;
|
||||
friction = clamp(friction, 0, FRACUNIT);
|
||||
|
||||
// The following check might seem odd. At the time of movement,
|
||||
// the move distance is multiplied by 'friction/0x10000', so a
|
||||
// higher friction value actually means 'less friction'.
|
||||
|
||||
// [RH] Twiddled these values so that velocity on ice (with
|
||||
// friction 0xf900) is the same as in Heretic/Hexen.
|
||||
if (friction >= ORIG_FRICTION) // ice
|
||||
// movefactor = ((0x10092 - friction)*(0x70))/0x158;
|
||||
movefactor = ((0x10092 - friction) * 1024) / 4352 + 568;
|
||||
else
|
||||
movefactor = ((friction - 0xDB34)*(0xA))/0x80;
|
||||
|
||||
// killough 8/28/98: prevent odd situations
|
||||
if (movefactor < 32)
|
||||
movefactor = 32;
|
||||
movefactor = FrictionToMoveFactor(friction);
|
||||
|
||||
for (s = -1; (s = P_FindSectorFromTag (tag,s)) >= 0; )
|
||||
{
|
||||
|
|
19
src/p_spec.h
19
src/p_spec.h
|
@ -172,6 +172,25 @@ void P_PlayerOnSpecialFlat (player_t *player, int floorType);
|
|||
void P_SectorDamage(int tag, int amount, FName type, const PClass *protectClass, int flags);
|
||||
void P_SetSectorFriction (int tag, int amount, bool alterFlag);
|
||||
|
||||
inline fixed_t FrictionToMoveFactor(fixed_t friction)
|
||||
{
|
||||
fixed_t movefactor;
|
||||
|
||||
// [RH] Twiddled these values so that velocity on ice (with
|
||||
// friction 0xf900) is the same as in Heretic/Hexen.
|
||||
if (friction >= ORIG_FRICTION) // ice
|
||||
// movefactor = ((0x10092 - friction)*(0x70))/0x158;
|
||||
movefactor = ((0x10092 - friction) * 1024) / 4352 + 568;
|
||||
else
|
||||
movefactor = ((friction - 0xDB34)*(0xA))/0x80;
|
||||
|
||||
// killough 8/28/98: prevent odd situations
|
||||
if (movefactor < 32)
|
||||
movefactor = 32;
|
||||
|
||||
return movefactor;
|
||||
}
|
||||
|
||||
void P_GiveSecret(AActor *actor, bool printmessage, bool playsound, int sectornum);
|
||||
|
||||
//
|
||||
|
|
|
@ -289,8 +289,8 @@ bool F7ZFile::Open(bool quiet)
|
|||
continue;
|
||||
}
|
||||
|
||||
nameUTF16.Resize(nameLength);
|
||||
nameASCII.Resize(nameLength);
|
||||
nameUTF16.Resize((unsigned)nameLength);
|
||||
nameASCII.Resize((unsigned)nameLength);
|
||||
SzArEx_GetFileNameUtf16(&Archive->DB, i, &nameUTF16[0]);
|
||||
for (size_t c = 0; c < nameLength; ++c)
|
||||
{
|
||||
|
|
|
@ -1297,6 +1297,17 @@ DEFINE_PROPERTY(gravity, F, Actor)
|
|||
defaults->gravity = i;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//==========================================================================
|
||||
DEFINE_PROPERTY(friction, F, Actor)
|
||||
{
|
||||
PROP_FIXED_PARM(i, 0);
|
||||
|
||||
if (i < 0) I_Error ("Friction must not be negative.");
|
||||
defaults->Friction = i;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//==========================================================================
|
||||
|
|
|
@ -18,6 +18,7 @@ ACTOR Actor native //: Thinker
|
|||
FloatSpeed 4
|
||||
FloatBobPhase -1 // randomly initialize by default
|
||||
Gravity 1
|
||||
Friction 1
|
||||
DamageFactor 1.0
|
||||
PushFactor 0.25
|
||||
WeaveIndexXY 0
|
||||
|
|
|
@ -162,8 +162,8 @@ Global
|
|||
{A7DE5C73-D623-4118-A48A-BDFD1FAE97D4}.Release|Win32.Build.0 = Release|Win32
|
||||
{A7DE5C73-D623-4118-A48A-BDFD1FAE97D4}.Release|x64.ActiveCfg = Release|x64
|
||||
{A7DE5C73-D623-4118-A48A-BDFD1FAE97D4}.Release|x64.Build.0 = Release|x64
|
||||
{9B465A9E-E5C7-4577-B559-3CA2F7AE7D96}.Debug|Win32.ActiveCfg = Release|Win32
|
||||
{9B465A9E-E5C7-4577-B559-3CA2F7AE7D96}.Debug|Win32.Build.0 = Release|Win32
|
||||
{9B465A9E-E5C7-4577-B559-3CA2F7AE7D96}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{9B465A9E-E5C7-4577-B559-3CA2F7AE7D96}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{9B465A9E-E5C7-4577-B559-3CA2F7AE7D96}.Debug|x64.ActiveCfg = Release|x64
|
||||
{9B465A9E-E5C7-4577-B559-3CA2F7AE7D96}.Debug|x64.Build.0 = Release|x64
|
||||
{9B465A9E-E5C7-4577-B559-3CA2F7AE7D96}.Release|Win32.ActiveCfg = Release|Win32
|
||||
|
|
Loading…
Reference in a new issue