This commit is contained in:
Christoph Oelckers 2016-09-22 09:06:34 +02:00
commit 1e6b99cebd
21 changed files with 113 additions and 33 deletions

View file

@ -70,6 +70,7 @@ CVAR (String, gender, "male", CVAR_USERINFO | CVAR_ARCHIVE);
CVAR (Bool, neverswitchonpickup, false, CVAR_USERINFO | CVAR_ARCHIVE);
CVAR (Float, movebob, 0.25f, CVAR_USERINFO | CVAR_ARCHIVE);
CVAR (Float, stillbob, 0.f, CVAR_USERINFO | CVAR_ARCHIVE);
CVAR (Float, wbobspeed, 1.f, CVAR_USERINFO | CVAR_ARCHIVE);
CVAR (String, playerclass, "Fighter", CVAR_USERINFO | CVAR_ARCHIVE);
enum
@ -83,6 +84,7 @@ enum
INFO_NeverSwitchOnPickup,
INFO_MoveBob,
INFO_StillBob,
INFO_WBobSpeed,
INFO_PlayerClass,
INFO_ColorSet,
};

View file

@ -337,6 +337,10 @@ struct userinfo_t : TMap<FName,FBaseCVar *>
{
return *static_cast<FFloatCVar *>(*CheckKey(NAME_StillBob));
}
float GetWBobSpeed() const
{
return *static_cast<FFloatCVar *>(*CheckKey(NAME_WBobSpeed));
}
int GetPlayerClassNum() const
{
return *static_cast<FIntCVar *>(*CheckKey(NAME_PlayerClass));

View file

@ -527,7 +527,7 @@ long MemoryReader::Seek (long offset, int origin)
break;
}
FilePos=clamp<long>(offset,0,Length-1);
FilePos=clamp<long>(offset,0,Length);
return 0;
}
@ -583,7 +583,7 @@ long MemoryArrayReader::Seek (long offset, int origin)
break;
}
FilePos=clamp<long>(offset,0,Length-1);
FilePos=clamp<long>(offset,0,Length);
return 0;
}

View file

@ -1291,6 +1291,9 @@ void G_FinishTravel ()
if (level.FromSnapshot)
{
FBehavior::StaticStartTypedScripts (SCRIPT_Return, pawn, true);
// [Nash] run REOPEN scripts upon map re-entry
FBehavior::StaticStartTypedScripts(SCRIPT_Reopen, NULL, false);
}
}

View file

@ -1668,7 +1668,7 @@ void APowerDamage::ModifyDamage(int damage, FName damageType, int &newdamage, bo
newdam = damage * 4;
}
if (Owner != NULL && newdam > damage) S_Sound(Owner, 5, ActiveSound, 1.0f, ATTN_NONE);
newdamage = newdam;
newdamage = damage = newdam;
}
if (Inventory != NULL) Inventory->ModifyDamage(damage, damageType, newdamage, passive);
}
@ -1743,7 +1743,7 @@ void APowerProtection::ModifyDamage(int damage, FName damageType, int &newdamage
newdam = damage / 4;
}
if (Owner != NULL && newdam < damage) S_Sound(Owner, CHAN_AUTO, ActiveSound, 1.0f, ATTN_NONE);
newdamage = newdam;
newdamage = damage = newdam;
}
if (Inventory != NULL)
{

View file

@ -222,6 +222,10 @@ bool AWeapon::HandlePickup (AInventory *item)
{
item->ItemFlags |= IF_PICKUPGOOD;
}
if (MaxAmount > 1) //[SP] If amount<maxamount do another pickup test of the weapon itself!
{
return Super::HandlePickup (item);
}
return true;
}
if (Inventory != NULL)

View file

@ -644,6 +644,7 @@ xx(ColorSet)
xx(NeverSwitchOnPickup)
xx(MoveBob)
xx(StillBob)
xx(WBobSpeed)
xx(PlayerClass)
xx(Wi_NoAutostartMap)

View file

@ -2822,7 +2822,8 @@ void FBehavior::StaticStartTypedScripts (WORD type, AActor *activator, bool alwa
"Lightning",
"Unloading",
"Disconnect",
"Return"
"Return",
"Reopen"
};
DPrintf(DMSG_NOTIFY, "Starting all scripts of type %d (%s)\n", type,
type < countof(TypeNames) ? TypeNames[type] : TypeNames[SCRIPT_Lightning - 1]);

View file

@ -272,6 +272,7 @@ enum
SCRIPT_Return = 15,
SCRIPT_Event = 16, // [BB]
SCRIPT_Kill = 17, // [JM]
SCRIPT_Reopen = 18, // [Nash]
};
// Script flags

View file

@ -524,6 +524,7 @@ void P_DropWeapon (player_t *player)
// A_WeaponReady every tic, and it looks bad if they don't bob smoothly.
//
// [XA] Added new bob styles and exposed bob properties. Thanks, Ryan Cordell!
// [SP] Added new user option for bob speed
//
//============================================================================
@ -551,8 +552,9 @@ void P_BobWeapon (player_t *player, float *x, float *y, double ticfrac)
for (int i = 0; i < 2; i++)
{
// Bob the weapon based on movement speed.
FAngle angle = (BobSpeed * 35 / TICRATE*(level.time - 1 + i)) * (360.f / 8192.f);
// Bob the weapon based on movement speed. ([SP] And user's bob speed setting)
FAngle angle = (BobSpeed * player->userinfo.GetWBobSpeed() * 35 /
TICRATE*(level.time - 1 + i)) * (360.f / 8192.f);
// [RH] Smooth transitions between bobbing and not-bobbing frames.
// This also fixes the bug where you can "stick" a weapon off-center by

View file

@ -44,6 +44,6 @@
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<key>NSSupportsAutomaticGraphicsSwitching</key>
<string>YES</string>
<true/>
</dict>
</plist>

View file

@ -59,7 +59,11 @@
#else
#include <dlfcn.h>
#ifdef __APPLE__
#define FLUIDSYNTHLIB "libfluidsynth.1.dylib"
#else // !__APPLE__
#define FLUIDSYNTHLIB "libfluidsynth.so.1"
#endif // __APPLE__
#endif
#define FLUID_REVERB_DEFAULT_ROOMSIZE 0.2f
@ -92,6 +96,8 @@
// PUBLIC DATA DEFINITIONS -------------------------------------------------
CVAR(String, fluid_lib, "", CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
CVAR(String, fluid_patchset, "", CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
CUSTOM_CVAR(Float, fluid_gain, 0.5, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
@ -689,23 +695,55 @@ bool FluidSynthMIDIDevice::LoadFluidSynth()
const char *libname;
#ifdef _WIN32
FluidSynthDLL = LoadLibrary((libname = FLUIDSYNTHLIB1));
if (FluidSynthDLL == NULL)
if (strlen(fluid_lib) > 0)
{
FluidSynthDLL = LoadLibrary((libname = FLUIDSYNTHLIB2));
if (FluidSynthDLL == NULL)
FluidSynthDLL = LoadLibrary(libname = fluid_lib);
if (nullptr == FluidSynthDLL)
{
Printf(TEXTCOLOR_RED "Could not load %s\n", libname);
}
}
else
{
FluidSynthDLL = nullptr;
}
if (nullptr == FluidSynthDLL)
{
FluidSynthDLL = LoadLibrary(libname = FLUIDSYNTHLIB1);
if (nullptr == FluidSynthDLL)
{
FluidSynthDLL = LoadLibrary(libname = FLUIDSYNTHLIB2);
if (nullptr == FluidSynthDLL)
{
Printf(TEXTCOLOR_RED "Could not load " FLUIDSYNTHLIB1 " or " FLUIDSYNTHLIB2 "\n");
return false;
}
}
}
#else
FluidSynthSO = dlopen((libname = FLUIDSYNTHLIB), RTLD_LAZY);
if (FluidSynthSO == NULL)
if (strlen(fluid_lib) > 0)
{
FluidSynthSO = dlopen(libname = fluid_lib, RTLD_LAZY);
if (nullptr == FluidSynthSO)
{
Printf(TEXTCOLOR_RED "Could not load %s: %s\n", libname, dlerror());
}
}
else
{
FluidSynthSO = nullptr;
}
if (nullptr == FluidSynthSO)
{
FluidSynthSO = dlopen(libname = FLUIDSYNTHLIB, RTLD_LAZY);
if (nullptr == FluidSynthSO)
{
Printf(TEXTCOLOR_RED "Could not load " FLUIDSYNTHLIB ": %s\n", dlerror());
return false;
}
}
#endif
for (size_t i = 0; i < countof(imports); ++i)

View file

@ -3373,6 +3373,19 @@ FxExpression *FxClassMember::Resolve(FCompileContext &ctx)
ExpEmit FxClassMember::Emit(VMFunctionBuilder *build)
{
if (~membervar->Flags & VARF_Native)
{ // Check if this is a user-defined variable.
// As of right now, FxClassMember is only ever used with FxSelf.
// This very user variable was defined in stateowner so if
// self (a0) != stateowner (a1) then the offset is most likely
// going to end up being totally wrong even if the variable was
// redefined in self which means we have to abort to avoid reading
// or writing to a random address and possibly crash.
build->Emit(OP_EQA_R, 1, 0, 1);
build->Emit(OP_JMP, 1);
build->Emit(OP_THROW, 2, X_BAD_SELF);
}
ExpEmit obj = classx->Emit(build);
assert(obj.RegType == REGT_POINTER);

View file

@ -1576,10 +1576,6 @@ DEFINE_PROPERTY(telefogdesttype, S, Actor)
DEFINE_PROPERTY(ripperlevel, I, Actor)
{
PROP_INT_PARM(id, 0);
if (id < 0)
{
I_Error ("RipperLevel must not be negative");
}
defaults->RipperLevel = id;
}
@ -1589,10 +1585,6 @@ DEFINE_PROPERTY(ripperlevel, I, Actor)
DEFINE_PROPERTY(riplevelmin, I, Actor)
{
PROP_INT_PARM(id, 0);
if (id < 0)
{
I_Error ("RipLevelMin must not be negative");
}
defaults->RipLevelMin = id;
}
@ -1602,10 +1594,6 @@ DEFINE_PROPERTY(riplevelmin, I, Actor)
DEFINE_PROPERTY(riplevelmax, I, Actor)
{
PROP_INT_PARM(id, 0);
if (id < 0)
{
I_Error ("RipLevelMax must not be negative");
}
defaults->RipLevelMax = id;
}

View file

@ -163,6 +163,7 @@ enum EVMAbortException
X_TOO_MANY_TRIES,
X_ARRAY_OUT_OF_BOUNDS,
X_DIVISION_BY_ZERO,
X_BAD_SELF,
};
class VMFunction : public DObject

View file

@ -371,7 +371,18 @@ void VMDisasm(FILE *out, const VMOP *code, int codesize, const VMScriptFunction
col = print_reg(out, 0, a, (mode & MODE_ATYPE) >> MODE_ASHIFT, 24, func);
if ((mode & MODE_BCTYPE) == MODE_BCTHROW)
{
mode = (code[i].a == 0) ? (MODE_BP | MODE_CUNUSED) : (MODE_BKP | MODE_CUNUSED);
if (code[i].a == 0)
{
mode = (MODE_BP | MODE_CUNUSED);
}
else if (code[i].a == 1)
{
mode = (MODE_BKP | MODE_CUNUSED);
}
else
{
mode = (MODE_BCJOINT | MODE_BCIMMS);
}
}
else if ((mode & MODE_BCTYPE) == MODE_BCCATCH)
{

View file

@ -616,12 +616,16 @@ begin:
ASSERTA(B);
throw((VMException *)reg.a[B]);
}
else
else if (a == 1)
{
ASSERTKA(B);
assert(konstatag[B] == ATAG_OBJECT);
throw((VMException *)konsta[B].o);
}
else
{
THROW(BC);
}
NEXTOP;
OP(CATCH):
// This instruction is handled by our own catch handler and should

View file

@ -440,6 +440,10 @@ int VMFrameStack::Call(VMFunction *func, VMValue *params, int numparams, VMRetur
case X_DIVISION_BY_ZERO:
Printf("division by zero.");
break;
case X_BAD_SELF:
Printf("invalid self pointer.");
break;
}
Printf("\n");

View file

@ -83,7 +83,8 @@ xx(RETI, reti, I8I16), // Copy immediate from BC to return value A, possibly re
xx(TRY, try, I24), // When an exception is thrown, start searching for a handler at pc + ABC
xx(UNTRY, untry, I8), // Pop A entries off the exception stack
xx(THROW, throw, THROW), // A == 0: Throw exception object pB
// A != 0: Throw exception object pkB
// A == 1: Throw exception object pkB
// A >= 2: Throw VM exception of type BC
xx(CATCH, catch, CATCH), // A == 0: continue search on next try
// A == 1: continue execution at instruction immediately following CATCH (catches any exception)
// A == 2: (pB == <type of exception thrown>) then pc++ ; next instruction must JMP to another CATCH

View file

@ -1802,6 +1802,7 @@ DSPLYMNU_MENUDIM = "Menu dim";
DSPLYMNU_DIMCOLOR = "Dim color";
DSPLYMNU_MOVEBOB = "View bob amount while moving";
DSPLYMNU_STILLBOB = "View bob amount while not moving";
DSPLYMNU_BOBSPEED = "Weapon bob speed";
// HUD Options
HUDMNU_TITLE = "HUD Options";

View file

@ -703,6 +703,7 @@ OptionMenu "VideoOptions"
ColorPicker "$DSPLYMNU_DIMCOLOR", "dimcolor"
Slider "$DSPLYMNU_MOVEBOB", "movebob", 0, 1.0, 0.05, 2
Slider "$DSPLYMNU_STILLBOB", "stillbob", 0, 1.0, 0.05, 2
Slider "$DSPLYMNU_BOBSPEED", "wbobspeed", 0, 2.0, 0.1, 2
}
//-------------------------------------------------------------------------------------------