This commit is contained in:
Christoph Oelckers 2014-07-31 00:44:59 +02:00
commit 09ae52e26b
23 changed files with 489 additions and 160 deletions

View file

@ -340,6 +340,7 @@ enum
MF7_NOTELESTOMP = 0x00000002, // cannot telefrag under any circumstances (even when set by MAPINFO) MF7_NOTELESTOMP = 0x00000002, // cannot telefrag under any circumstances (even when set by MAPINFO)
MF7_ALWAYSTELEFRAG = 0x00000004, // will unconditionally be telefragged when in the way. Overrides all other settings. MF7_ALWAYSTELEFRAG = 0x00000004, // will unconditionally be telefragged when in the way. Overrides all other settings.
MF7_HANDLENODELAY = 0x00000008, // respect NoDelay state flag MF7_HANDLENODELAY = 0x00000008, // respect NoDelay state flag
MF7_WEAPONSPAWN = 0x00000010, // subject to DF_NO_COOP_WEAPON_SPAWN dmflag
// --- mobj.renderflags --- // --- mobj.renderflags ---
@ -905,6 +906,7 @@ public:
fixed_t wallbouncefactor; // The bounce factor for walls can be different. fixed_t wallbouncefactor; // The bounce factor for walls can be different.
int bouncecount; // Strife's grenades only bounce twice before exploding int bouncecount; // Strife's grenades only bounce twice before exploding
fixed_t gravity; // [GRB] Gravity factor fixed_t gravity; // [GRB] Gravity factor
fixed_t Friction;
int FastChaseStrafeCount; int FastChaseStrafeCount;
fixed_t pushfactor; fixed_t pushfactor;
int lastpush; int lastpush;

View file

@ -1276,7 +1276,7 @@ void NetUpdate (void)
// listen for other packets // listen for other packets
GetPackets (); GetPackets ();
if (!demoplayback) if (!resendOnly)
{ {
// ideally nettics[0] should be 1 - 3 tics above lowtic // ideally nettics[0] should be 1 - 3 tics above lowtic
// if we are consistantly slower, speed up time // if we are consistantly slower, speed up time
@ -1323,7 +1323,7 @@ void NetUpdate (void)
} }
oldnettics = nettics[0]; oldnettics = nettics[0];
} }
}// !demoplayback }
} }

View file

@ -154,7 +154,7 @@ static const char * const ActorNames_init[]=
"RocketAmmo", "RocketAmmo",
"RocketBox", "RocketBox",
"Cell", "Cell",
"CellBox", "CellPack",
"Shell", "Shell",
"ShellBox", "ShellBox",
"Backpack", "Backpack",

View file

@ -122,10 +122,11 @@ FRandom pr_acs ("ACS");
struct CallReturn 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), : ReturnFunction(func),
ReturnModule(module), ReturnModule(module),
ReturnLocals(locals), ReturnLocals(locals),
ReturnArrays(arrays),
ReturnAddress(pc), ReturnAddress(pc),
bDiscardResult(discard), bDiscardResult(discard),
EntryInstrCount(runaway) EntryInstrCount(runaway)
@ -134,6 +135,7 @@ struct CallReturn
ScriptFunction *ReturnFunction; ScriptFunction *ReturnFunction;
FBehavior *ReturnModule; FBehavior *ReturnModule;
SDWORD *ReturnLocals; SDWORD *ReturnLocals;
ACSLocalArrays *ReturnArrays;
int ReturnAddress; int ReturnAddress;
int bDiscardResult; int bDiscardResult;
unsigned int EntryInstrCount; 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) FBehavior::FBehavior (int lumpnum, FileReader * fr, int len)
{ {
BYTE *object; BYTE *object;
@ -1822,12 +1844,45 @@ FBehavior::FBehavior (int lumpnum, FileReader * fr, int len)
{ {
DWORD *chunk; DWORD *chunk;
Functions = FindChunk (MAKE_ID('F','U','N','C')); // Load functions
if (Functions != NULL) BYTE *funcs;
Functions = NULL;
funcs = FindChunk (MAKE_ID('F','U','N','C'));
if (funcs != NULL)
{ {
NumFunctions = LittleLong(((DWORD *)Functions)[1]) / 8; NumFunctions = LittleLong(((DWORD *)funcs)[1]) / 8;
Functions += 8; funcs += 8;
FunctionProfileData = new ACSProfileInfo[NumFunctions]; 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 // Load JUMP points
@ -2135,6 +2190,11 @@ FBehavior::~FBehavior ()
delete[] ArrayStore; delete[] ArrayStore;
ArrayStore = NULL; ArrayStore = NULL;
} }
if (Functions != NULL)
{
delete[] Functions;
Functions = NULL;
}
if (FunctionProfileData != NULL) if (FunctionProfileData != NULL)
{ {
delete[] FunctionProfileData; 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) // Load script names (if any)
scripts.b = FindChunk(MAKE_ID('S','N','A','M')); scripts.b = FindChunk(MAKE_ID('S','N','A','M'));
if (scripts.dw != NULL) if (scripts.dw != NULL)
@ -3530,7 +3605,8 @@ enum
APROP_MeleeRange = 38, APROP_MeleeRange = 38,
APROP_ViewHeight = 39, APROP_ViewHeight = 39,
APROP_AttackZOffset = 40, APROP_AttackZOffset = 40,
APROP_StencilColor = 41 APROP_StencilColor = 41,
APROP_Friction = 42,
}; };
// These are needed for ACS's APROP_RenderStyle // These are needed for ACS's APROP_RenderStyle
@ -3764,6 +3840,9 @@ void DLevelScript::DoSetActorProperty (AActor *actor, int property, int value)
actor->SetShade(value); actor->SetShade(value);
break; break;
case APROP_Friction:
actor->Friction = value;
default: default:
// do nothing. // do nothing.
break; 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_Species: return GlobalACSStrings.AddString(actor->GetSpecies(), stack, stackdepth);
case APROP_NameTag: return GlobalACSStrings.AddString(actor->GetTag(), stack, stackdepth); case APROP_NameTag: return GlobalACSStrings.AddString(actor->GetTag(), stack, stackdepth);
case APROP_StencilColor:return actor->fillcolor; case APROP_StencilColor:return actor->fillcolor;
case APROP_Friction: return actor->Friction;
default: return 0; default: return 0;
} }
@ -5460,14 +5540,50 @@ inline int getshort (int *&pc)
return res; 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 () int DLevelScript::RunScript ()
{ {
DACSThinker *controller = DACSThinker::ActiveThinker; DACSThinker *controller = DACSThinker::ActiveThinker;
SDWORD *locals = localvars; SDWORD *locals = localvars;
ACSLocalArrays noarrays;
ACSLocalArrays *localarrays = &noarrays;
ScriptFunction *activeFunction = NULL; ScriptFunction *activeFunction = NULL;
FRemapTable *translation = 0; FRemapTable *translation = 0;
int resultValue = 1; 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 // 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; const int specialargmask = ((level.flags2 & LEVEL2_HEXENHACK) && activeBehavior->GetFormat() == ACS_Old) ? 255 : ~0;
@ -5832,9 +5948,10 @@ int DLevelScript::RunScript ()
} }
sp += i; sp += i;
::new(&Stack[sp]) CallReturn(activeBehavior->PC2Ofs(pc), activeFunction, ::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); sp += (sizeof(CallReturn) + sizeof(int) - 1) / sizeof(int);
pc = module->Ofs2PC (func->Address); pc = module->Ofs2PC (func->Address);
localarrays = &func->LocalArrays;
activeFunction = func; activeFunction = func;
activeBehavior = module; activeBehavior = module;
fmt = module->GetFormat(); fmt = module->GetFormat();
@ -5868,6 +5985,7 @@ int DLevelScript::RunScript ()
activeBehavior = ret->ReturnModule; activeBehavior = ret->ReturnModule;
fmt = activeBehavior->GetFormat(); fmt = activeBehavior->GetFormat();
locals = ret->ReturnLocals; locals = ret->ReturnLocals;
localarrays = ret->ReturnArrays;
if (!ret->bDiscardResult) if (!ret->bDiscardResult)
{ {
Stack[sp++] = value; Stack[sp++] = value;
@ -5966,6 +6084,11 @@ int DLevelScript::RunScript ()
sp--; sp--;
break; break;
case PCD_ASSIGNSCRIPTARRAY:
localarrays->Set(locals, NEXTBYTE, STACK(2), STACK(1));
sp -= 2;
break;
case PCD_ASSIGNMAPARRAY: case PCD_ASSIGNMAPARRAY:
activeBehavior->SetArrayVal (*(activeBehavior->MapVars[NEXTBYTE]), STACK(2), STACK(1)); activeBehavior->SetArrayVal (*(activeBehavior->MapVars[NEXTBYTE]), STACK(2), STACK(1));
sp -= 2; sp -= 2;
@ -5997,6 +6120,10 @@ int DLevelScript::RunScript ()
PushToStack (ACS_GlobalVars[NEXTBYTE]); PushToStack (ACS_GlobalVars[NEXTBYTE]);
break; break;
case PCD_PUSHSCRIPTARRAY:
STACK(1) = localarrays->Get(locals, NEXTBYTE, STACK(1));
break;
case PCD_PUSHMAPARRAY: case PCD_PUSHMAPARRAY:
STACK(1) = activeBehavior->GetArrayVal (*(activeBehavior->MapVars[NEXTBYTE]), STACK(1)); STACK(1) = activeBehavior->GetArrayVal (*(activeBehavior->MapVars[NEXTBYTE]), STACK(1));
break; break;
@ -6029,6 +6156,14 @@ int DLevelScript::RunScript ()
sp--; sp--;
break; 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: case PCD_ADDMAPARRAY:
{ {
int a = *(activeBehavior->MapVars[NEXTBYTE]); int a = *(activeBehavior->MapVars[NEXTBYTE]);
@ -6074,6 +6209,14 @@ int DLevelScript::RunScript ()
sp--; sp--;
break; 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: case PCD_SUBMAPARRAY:
{ {
int a = *(activeBehavior->MapVars[NEXTBYTE]); int a = *(activeBehavior->MapVars[NEXTBYTE]);
@ -6119,6 +6262,14 @@ int DLevelScript::RunScript ()
sp--; sp--;
break; 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: case PCD_MULMAPARRAY:
{ {
int a = *(activeBehavior->MapVars[NEXTBYTE]); int a = *(activeBehavior->MapVars[NEXTBYTE]);
@ -6192,6 +6343,19 @@ int DLevelScript::RunScript ()
} }
break; 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: case PCD_DIVMAPARRAY:
if (STACK(1) == 0) if (STACK(1) == 0)
{ {
@ -6280,6 +6444,19 @@ int DLevelScript::RunScript ()
} }
break; 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: case PCD_MODMAPARRAY:
if (STACK(1) == 0) if (STACK(1) == 0)
{ {
@ -6341,6 +6518,14 @@ int DLevelScript::RunScript ()
sp--; sp--;
break; 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: case PCD_ANDMAPARRAY:
{ {
int a = *(activeBehavior->MapVars[NEXTBYTE]); int a = *(activeBehavior->MapVars[NEXTBYTE]);
@ -6386,6 +6571,14 @@ int DLevelScript::RunScript ()
sp--; sp--;
break; 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: case PCD_EORMAPARRAY:
{ {
int a = *(activeBehavior->MapVars[NEXTBYTE]); int a = *(activeBehavior->MapVars[NEXTBYTE]);
@ -6431,6 +6624,14 @@ int DLevelScript::RunScript ()
sp--; sp--;
break; 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: case PCD_ORMAPARRAY:
{ {
int a = *(activeBehavior->MapVars[NEXTBYTE]); int a = *(activeBehavior->MapVars[NEXTBYTE]);
@ -6477,6 +6678,14 @@ int DLevelScript::RunScript ()
sp--; sp--;
break; 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: case PCD_LSMAPARRAY:
{ {
int a = *(activeBehavior->MapVars[NEXTBYTE]); int a = *(activeBehavior->MapVars[NEXTBYTE]);
@ -6522,6 +6731,14 @@ int DLevelScript::RunScript ()
sp--; sp--;
break; 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: case PCD_RSMAPARRAY:
{ {
int a = *(activeBehavior->MapVars[NEXTBYTE]); int a = *(activeBehavior->MapVars[NEXTBYTE]);
@ -6564,6 +6781,14 @@ int DLevelScript::RunScript ()
++ACS_GlobalVars[NEXTBYTE]; ++ACS_GlobalVars[NEXTBYTE];
break; 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: case PCD_INCMAPARRAY:
{ {
int a = *(activeBehavior->MapVars[NEXTBYTE]); int a = *(activeBehavior->MapVars[NEXTBYTE]);
@ -6605,6 +6830,14 @@ int DLevelScript::RunScript ()
--ACS_GlobalVars[NEXTBYTE]; --ACS_GlobalVars[NEXTBYTE];
break; 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: case PCD_DECMAPARRAY:
{ {
int a = *(activeBehavior->MapVars[NEXTBYTE]); int a = *(activeBehavior->MapVars[NEXTBYTE]);
@ -7031,37 +7264,35 @@ scriptwait:
} }
break; 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 // [JB] Print map character array
case PCD_PRINTMAPCHARARRAY: case PCD_PRINTMAPCHARARRAY:
case PCD_PRINTMAPCHRANGE: case PCD_PRINTMAPCHRANGE:
{ {
int capacity, offset; int capacity, offset, a, c;
if (CharArrayParms(capacity, offset, a, Stack, sp, pcd == PCD_PRINTMAPCHRANGE))
if (pcd == PCD_PRINTMAPCHRANGE)
{ {
capacity = STACK(1); while (capacity-- && (c = activeBehavior->GetArrayVal (a, offset)) != '\0')
offset = STACK(2);
if (capacity < 1 || offset < 0)
{ {
sp -= 4;
break;
}
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; work += (char)c;
offset++; offset++;
} }
sp-= 2; }
} }
break; break;
@ -7069,32 +7300,15 @@ scriptwait:
case PCD_PRINTWORLDCHARARRAY: case PCD_PRINTWORLDCHARARRAY:
case PCD_PRINTWORLDCHRANGE: case PCD_PRINTWORLDCHRANGE:
{ {
int capacity, offset; int capacity, offset, a, c;
if (pcd == PCD_PRINTWORLDCHRANGE) if (CharArrayParms(capacity, offset, a, Stack, sp, pcd == PCD_PRINTWORLDCHRANGE))
{ {
capacity = STACK(1); while (capacity-- && (c = ACS_WorldArrays[a][offset]) != '\0')
offset = STACK(2);
if (capacity < 1 || offset < 0)
{ {
sp -= 4;
break;
}
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; work += (char)c;
offset++; offset++;
} }
sp-= 2; }
} }
break; break;
@ -7102,32 +7316,15 @@ scriptwait:
case PCD_PRINTGLOBALCHARARRAY: case PCD_PRINTGLOBALCHARARRAY:
case PCD_PRINTGLOBALCHRANGE: case PCD_PRINTGLOBALCHRANGE:
{ {
int capacity, offset; int capacity, offset, a, c;
if (pcd == PCD_PRINTGLOBALCHRANGE) if (CharArrayParms(capacity, offset, a, Stack, sp, pcd == PCD_PRINTGLOBALCHRANGE))
{ {
capacity = STACK(1); while (capacity-- && (c = ACS_GlobalArrays[a][offset]) != '\0')
offset = STACK(2);
if (capacity < 1 || offset < 0)
{ {
sp -= 4;
break;
}
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; work += (char)c;
offset++; offset++;
} }
sp-= 2; }
} }
break; break;
@ -8674,6 +8871,7 @@ scriptwait:
} }
break; break;
case PCD_STRCPYTOSCRIPTCHRANGE:
case PCD_STRCPYTOMAPCHRANGE: case PCD_STRCPYTOMAPCHRANGE:
case PCD_STRCPYTOWORLDCHRANGE: case PCD_STRCPYTOWORLDCHRANGE:
case PCD_STRCPYTOGLOBALCHRANGE: case PCD_STRCPYTOGLOBALCHRANGE:
@ -8715,6 +8913,19 @@ scriptwait:
switch (pcd) switch (pcd)
{ {
case PCD_STRCPYTOSCRIPTCHRANGE:
{
int a = STACK(5);
while (capacity-- > 0)
{
localarrays->Set(locals, 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_STRCPYTOMAPCHRANGE: case PCD_STRCPYTOMAPCHRANGE:
{ {
int a = STACK(5); int a = STACK(5);
@ -8751,7 +8962,6 @@ scriptwait:
Stack[sp-6] = !(*lookup); // true/success if only terminating 0 was not copied Stack[sp-6] = !(*lookup); // true/success if only terminating 0 was not copied
} }
break; break;
} }
sp -= 5; sp -= 5;
} }

View file

@ -144,6 +144,51 @@ struct ProfileCollector
int Index; 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 // The in-memory version
struct ScriptPtr struct ScriptPtr
{ {
@ -153,6 +198,7 @@ struct ScriptPtr
BYTE ArgCount; BYTE ArgCount;
WORD VarCount; WORD VarCount;
WORD Flags; WORD Flags;
ACSLocalArrays LocalArrays;
ACSProfileInfo ProfileData; ACSProfileInfo ProfileData;
}; };
@ -189,7 +235,7 @@ struct ScriptFlagsPtr
WORD Flags; WORD Flags;
}; };
struct ScriptFunction struct ScriptFunctionInFile
{ {
BYTE ArgCount; BYTE ArgCount;
BYTE LocalCount; BYTE LocalCount;
@ -198,6 +244,16 @@ struct ScriptFunction
DWORD Address; DWORD Address;
}; };
struct ScriptFunction
{
BYTE ArgCount;
BYTE HasReturnValue;
BYTE ImportNum;
int LocalCount;
DWORD Address;
ACSLocalArrays LocalArrays;
};
// Script types // Script types
enum enum
{ {
@ -285,7 +341,7 @@ private:
BYTE *Chunks; BYTE *Chunks;
ScriptPtr *Scripts; ScriptPtr *Scripts;
int NumScripts; int NumScripts;
BYTE *Functions; ScriptFunction *Functions;
ACSProfileInfo *FunctionProfileData; ACSProfileInfo *FunctionProfileData;
int NumFunctions; int NumFunctions;
ArrayInfo *ArrayStore; ArrayInfo *ArrayStore;
@ -694,8 +750,25 @@ public:
PCD_SCRIPTWAITNAMED, PCD_SCRIPTWAITNAMED,
PCD_TRANSLATIONRANGE3, PCD_TRANSLATIONRANGE3,
PCD_GOTOSTACK, 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 // Some constants used by ACS scripts

View file

@ -16,6 +16,7 @@
#include "p_setup.h" #include "p_setup.h"
#include "g_level.h" #include "g_level.h"
#include "r_data/colormaps.h" #include "r_data/colormaps.h"
#include "gi.h"
// MACROS ------------------------------------------------------------------ // MACROS ------------------------------------------------------------------
@ -361,9 +362,8 @@ static bool P_LoadBloodMap (BYTE *data, size_t len, FMapThing **mapthings, int *
// BUILD info from the map we need. (Sprites are ignored.) // BUILD info from the map we need. (Sprites are ignored.)
LoadSectors (bsec); LoadSectors (bsec);
LoadWalls (bwal, numWalls, bsec); LoadWalls (bwal, numWalls, bsec);
*mapthings = new FMapThing[numsprites + 1]; *mapthings = new FMapThing[numsprites];
CreateStartSpot ((fixed_t *)infoBlock, *mapthings); *numspr = LoadSprites (bspr, xspr, numsprites, bsec, *mapthings);
*numspr = 1 + LoadSprites (bspr, xspr, numsprites, bsec, *mapthings + 1);
delete[] bsec; delete[] bsec;
delete[] bwal; delete[] bwal;
@ -687,6 +687,8 @@ static int LoadSprites (spritetype *sprites, Xsprite *xsprites, int numsprites,
{ {
int count = 0; int count = 0;
memset(mapthings, 0, sizeof(*mapthings)*numsprites);
for (int i = 0; i < numsprites; ++i) for (int i = 0; i < numsprites; ++i)
{ {
mapthings[count].thingid = 0; mapthings[count].thingid = 0;
@ -699,18 +701,31 @@ static int LoadSprites (spritetype *sprites, Xsprite *xsprites, int numsprites,
mapthings[count].flags = MTF_SINGLE|MTF_COOPERATIVE|MTF_DEATHMATCH; mapthings[count].flags = MTF_SINGLE|MTF_COOPERATIVE|MTF_DEATHMATCH;
mapthings[count].special = 0; mapthings[count].special = 0;
mapthings[count].gravity = FRACUNIT; mapthings[count].gravity = FRACUNIT;
mapthings[count].RenderStyle = STYLE_Count;
mapthings[count].alpha = -1;
mapthings[count].health = -1;
if (xsprites != NULL && sprites[i].lotag == 710) if (xsprites != NULL && sprites[i].lotag == 710)
{ // Blood ambient sound { // Blood ambient sound
mapthings[count].args[0] = xsprites[i].Data3; mapthings[count].args[0] = xsprites[i].Data3;
// I am totally guessing abount the volume level. 50 seems to be a pretty // I am totally guessing about the volume level. 50 seems to be a pretty
// typical value for Blood's standard maps, so I assume it's 100-based. // typical value for Blood's standard maps, so I assume it's 100-based.
mapthings[count].args[1] = xsprites[i].Data4; mapthings[count].args[1] = xsprites[i].Data4;
mapthings[count].args[2] = xsprites[i].Data1; mapthings[count].args[2] = xsprites[i].Data1;
mapthings[count].args[3] = xsprites[i].Data2; mapthings[count].args[3] = xsprites[i].Data2;
mapthings[count].args[4] = 0;
mapthings[count].type = 14065; mapthings[count].type = 14065;
} }
else if (xsprites != NULL && sprites[i].lotag == 1)
{ // Blood player start
if (xsprites[i].Data1 < 4)
mapthings[count].type = 1 + xsprites[i].Data1;
else
mapthings[count].type = gameinfo.player5start + xsprites[i].Data1 - 4;
}
else if (xsprites != NULL && sprites[i].lotag == 2)
{ // Bloodbath start
mapthings[count].type = 11;
}
else else
{ {
if (sprites[i].cstat & (16|32|32768)) continue; if (sprites[i].cstat & (16|32|32768)) continue;

View file

@ -1014,7 +1014,7 @@ bool P_CheckNodes(MapData * map, bool rebuilt, int buildtime)
// Building nodes in debug is much slower so let's cache them only if cachetime is 0 // Building nodes in debug is much slower so let's cache them only if cachetime is 0
buildtime = 0; buildtime = 0;
#endif #endif
if (gl_cachenodes && buildtime/1000.f >= gl_cachetime) if (level.maptype != MAPTYPE_BUILD && gl_cachenodes && buildtime/1000.f >= gl_cachetime)
{ {
DPrintf("Caching nodes\n"); DPrintf("Caching nodes\n");
CreateCachedNodes(map); CreateCachedNodes(map);

View file

@ -555,6 +555,12 @@ 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) if (frictionfactor)
*frictionfactor = movefactor; *frictionfactor = movefactor;

View file

@ -4724,7 +4724,7 @@ AActor *P_SpawnMapThing (FMapThing *mthing, int position)
// [RH] don't spawn extra weapons in coop if so desired // [RH] don't spawn extra weapons in coop if so desired
if (multiplayer && !deathmatch && (dmflags & DF_NO_COOP_WEAPON_SPAWN)) if (multiplayer && !deathmatch && (dmflags & DF_NO_COOP_WEAPON_SPAWN))
{ {
if (i->IsDescendantOf (RUNTIME_CLASS(AWeapon))) if (GetDefaultByType(i)->flags7 & MF7_WEAPONSPAWN)
{ {
if ((mthing->flags & (MTF_DEATHMATCH|MTF_SINGLE)) == MTF_DEATHMATCH) if ((mthing->flags & (MTF_DEATHMATCH|MTF_SINGLE)) == MTF_DEATHMATCH)
return NULL; return NULL;

View file

@ -312,7 +312,6 @@ MapData *P_OpenMapData(const char * mapname, bool justcheck)
if (map->Encrypted) if (map->Encrypted)
{ // If it's encrypted, then it's a Blood file, presumably a map. { // If it's encrypted, then it's a Blood file, presumably a map.
map->MapLumps[0].Reader = map->file = Wads.ReopenLumpNum(lump_name);
if (!P_IsBuildMap(map)) if (!P_IsBuildMap(map))
{ {
delete map; delete map;

View file

@ -1990,26 +1990,12 @@ void P_SetSectorFriction (int tag, int amount, bool alterFlag)
friction = (0x1EB8*amount)/0x80 + 0xD001; friction = (0x1EB8*amount)/0x80 + 0xD001;
// killough 8/28/98: prevent odd situations // killough 8/28/98: prevent odd situations
if (friction > FRACUNIT) friction = clamp(friction, 0, FRACUNIT);
friction = FRACUNIT;
if (friction < 0)
friction = 0;
// The following check might seem odd. At the time of movement, // The following check might seem odd. At the time of movement,
// the move distance is multiplied by 'friction/0x10000', so a // the move distance is multiplied by 'friction/0x10000', so a
// higher friction value actually means 'less friction'. // higher friction value actually means 'less friction'.
movefactor = FrictionToMoveFactor(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;
for (s = -1; (s = P_FindSectorFromTag (tag,s)) >= 0; ) for (s = -1; (s = P_FindSectorFromTag (tag,s)) >= 0; )
{ {

View file

@ -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_SectorDamage(int tag, int amount, FName type, const PClass *protectClass, int flags);
void P_SetSectorFriction (int tag, int amount, bool alterFlag); 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); void P_GiveSecret(AActor *actor, bool printmessage, bool playsound, int sectornum);
// //

View file

@ -925,8 +925,6 @@ void R_InitSprites ()
numskins++; numskins++;
} }
SpriteFrames.Clear();
// [RH] Do some preliminary setup // [RH] Do some preliminary setup
if (skins != NULL) delete [] skins; if (skins != NULL) delete [] skins;
skins = new FPlayerSkin[numskins]; skins = new FPlayerSkin[numskins];

View file

@ -289,8 +289,8 @@ bool F7ZFile::Open(bool quiet)
continue; continue;
} }
nameUTF16.Resize(nameLength); nameUTF16.Resize((unsigned)nameLength);
nameASCII.Resize(nameLength); nameASCII.Resize((unsigned)nameLength);
SzArEx_GetFileNameUtf16(&Archive->DB, i, &nameUTF16[0]); SzArEx_GetFileNameUtf16(&Archive->DB, i, &nameUTF16[0]);
for (size_t c = 0; c < nameLength; ++c) for (size_t c = 0; c < nameLength; ++c)
{ {

View file

@ -511,8 +511,6 @@ int S_AddSoundLump (const char *logicalname, int lump)
newsfx.LimitRange = 256*256; newsfx.LimitRange = 256*256;
newsfx.bRandomHeader = false; newsfx.bRandomHeader = false;
newsfx.bPlayerReserve = false; newsfx.bPlayerReserve = false;
newsfx.bForce11025 = false;
newsfx.bForce22050 = false;
newsfx.bLoadRAW = false; newsfx.bLoadRAW = false;
newsfx.bPlayerCompat = false; newsfx.bPlayerCompat = false;
newsfx.b16bit = false; newsfx.b16bit = false;
@ -520,6 +518,7 @@ int S_AddSoundLump (const char *logicalname, int lump)
newsfx.bSingular = false; newsfx.bSingular = false;
newsfx.bTentative = false; newsfx.bTentative = false;
newsfx.bPlayerSilent = false; newsfx.bPlayerSilent = false;
newsfx.RawRate = 0;
newsfx.link = sfxinfo_t::NO_LINK; newsfx.link = sfxinfo_t::NO_LINK;
newsfx.Rolloff.RolloffType = ROLLOFF_Doom; newsfx.Rolloff.RolloffType = ROLLOFF_Doom;
newsfx.Rolloff.MinDistance = 0; newsfx.Rolloff.MinDistance = 0;
@ -1414,13 +1413,17 @@ static void S_AddBloodSFX (int lumpnum)
{ {
const char *name = Wads.GetLumpFullName(lumpnum); const char *name = Wads.GetLumpFullName(lumpnum);
sfxnum = S_AddSound(name, rawlump); sfxnum = S_AddSound(name, rawlump);
if (sfx->Format == 5) if (sfx->Format < 5 || sfx->Format > 12)
{ { // [0..4] + invalid formats
S_sfx[sfxnum].bForce22050 = true; S_sfx[sfxnum].RawRate = 11025;
} }
else // I don't know any other formats for this else if (sfx->Format < 9)
{ { // [5..8]
S_sfx[sfxnum].bForce11025 = true; S_sfx[sfxnum].RawRate = 22050;
}
else
{ // [9..12]
S_sfx[sfxnum].RawRate = 44100;
} }
S_sfx[sfxnum].bLoadRAW = true; S_sfx[sfxnum].bLoadRAW = true;
S_sfx[sfxnum].LoopStart = LittleLong(sfx->LoopStart); S_sfx[sfxnum].LoopStart = LittleLong(sfx->LoopStart);
@ -1433,7 +1436,7 @@ static void S_AddBloodSFX (int lumpnum)
ambient->periodmax = 0; ambient->periodmax = 0;
ambient->volume = 1; ambient->volume = 1;
ambient->attenuation = 1; ambient->attenuation = 1;
ambient->sound = name; ambient->sound = FSoundID(sfxnum);
} }
} }
@ -2231,7 +2234,7 @@ void AAmbientSound::BeginPlay ()
// //
// AmbientSound :: Activate // AmbientSound :: Activate
// //
// Starts playing a sound (or does nothing of the sound is already playing). // Starts playing a sound (or does nothing if the sound is already playing).
// //
//========================================================================== //==========================================================================

View file

@ -1334,7 +1334,7 @@ sfxinfo_t *S_LoadSound(sfxinfo_t *sfx)
if (sfx->bLoadRAW) if (sfx->bLoadRAW)
{ {
len = Wads.LumpLength (sfx->lumpnum); len = Wads.LumpLength (sfx->lumpnum);
frequency = (sfx->bForce22050 ? 22050 : 11025); frequency = sfx->RawRate;
} }
else else
{ {

View file

@ -49,8 +49,6 @@ struct sfxinfo_t
WORD bRandomHeader:1; WORD bRandomHeader:1;
WORD bPlayerReserve:1; WORD bPlayerReserve:1;
WORD bForce11025:1;
WORD bForce22050:1;
WORD bLoadRAW:1; WORD bLoadRAW:1;
WORD bPlayerCompat:1; WORD bPlayerCompat:1;
WORD b16bit:1; WORD b16bit:1;
@ -59,6 +57,8 @@ struct sfxinfo_t
WORD bTentative:1; WORD bTentative:1;
WORD bPlayerSilent:1; // This player sound is intentionally silent. WORD bPlayerSilent:1; // This player sound is intentionally silent.
WORD RawRate; // Sample rate to use when bLoadRAW is true
int LoopStart; // -1 means no specific loop defined int LoopStart; // -1 means no specific loop defined
unsigned int link; unsigned int link;

View file

@ -964,6 +964,7 @@ void FTextureManager::SortTexturesByType(int start, int end)
void FTextureManager::Init() void FTextureManager::Init()
{ {
DeleteAll(); DeleteAll();
SpriteFrames.Clear();
// Init Build Tile data if it hasn't been done already // Init Build Tile data if it hasn't been done already
if (BuildTileFiles.Size() == 0) CountBuildTiles (); if (BuildTileFiles.Size() == 0) CountBuildTiles ();
FTexture::InitGrayMap(); FTexture::InitGrayMap();

View file

@ -240,6 +240,7 @@ static FFlagDef ActorFlags[]=
DEFINE_FLAG(MF7, NEVERTARGET, AActor, flags7), DEFINE_FLAG(MF7, NEVERTARGET, AActor, flags7),
DEFINE_FLAG(MF7, NOTELESTOMP, AActor, flags7), DEFINE_FLAG(MF7, NOTELESTOMP, AActor, flags7),
DEFINE_FLAG(MF7, ALWAYSTELEFRAG, AActor, flags7), DEFINE_FLAG(MF7, ALWAYSTELEFRAG, AActor, flags7),
DEFINE_FLAG(MF7, WEAPONSPAWN, AActor, flags7),
// Effect flags // Effect flags
DEFINE_FLAG(FX, VISIBILITYPULSE, AActor, effects), DEFINE_FLAG(FX, VISIBILITYPULSE, AActor, effects),

View file

@ -1297,6 +1297,17 @@ DEFINE_PROPERTY(gravity, F, Actor)
defaults->gravity = i; 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;
}
//========================================================================== //==========================================================================
// //
//========================================================================== //==========================================================================

View file

@ -18,6 +18,7 @@ ACTOR Actor native //: Thinker
FloatSpeed 4 FloatSpeed 4
FloatBobPhase -1 // randomly initialize by default FloatBobPhase -1 // randomly initialize by default
Gravity 1 Gravity 1
Friction 1
DamageFactor 1.0 DamageFactor 1.0
PushFactor 0.25 PushFactor 0.25
WeaveIndexXY 0 WeaveIndexXY 0

View file

@ -335,6 +335,7 @@ Actor Weapon : Inventory native
Weapon.BobSpeed 1.0 Weapon.BobSpeed 1.0
Weapon.BobRangeX 1.0 Weapon.BobRangeX 1.0
Weapon.BobRangeY 1.0 Weapon.BobRangeY 1.0
+WEAPONSPAWN
States States
{ {
LightDone: LightDone:
@ -362,4 +363,7 @@ Actor WeaponHolder : Inventory native
+INVENTORY.UNDROPPABLE +INVENTORY.UNDROPPABLE
} }
Actor WeaponPiece : Inventory native {} Actor WeaponPiece : Inventory native
{
+WEAPONSPAWN
}

View file

@ -162,8 +162,8 @@ Global
{A7DE5C73-D623-4118-A48A-BDFD1FAE97D4}.Release|Win32.Build.0 = Release|Win32 {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.ActiveCfg = Release|x64
{A7DE5C73-D623-4118-A48A-BDFD1FAE97D4}.Release|x64.Build.0 = 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.ActiveCfg = Debug|Win32
{9B465A9E-E5C7-4577-B559-3CA2F7AE7D96}.Debug|Win32.Build.0 = Release|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.ActiveCfg = Release|x64
{9B465A9E-E5C7-4577-B559-3CA2F7AE7D96}.Debug|x64.Build.0 = Release|x64 {9B465A9E-E5C7-4577-B559-3CA2F7AE7D96}.Debug|x64.Build.0 = Release|x64
{9B465A9E-E5C7-4577-B559-3CA2F7AE7D96}.Release|Win32.ActiveCfg = Release|Win32 {9B465A9E-E5C7-4577-B559-3CA2F7AE7D96}.Release|Win32.ActiveCfg = Release|Win32