Merge branch 'master' into json

This commit is contained in:
Christoph Oelckers 2016-09-22 09:09:48 +02:00
commit f0e8e860f1
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 (Bool, neverswitchonpickup, false, CVAR_USERINFO | CVAR_ARCHIVE);
CVAR (Float, movebob, 0.25f, CVAR_USERINFO | CVAR_ARCHIVE); CVAR (Float, movebob, 0.25f, CVAR_USERINFO | CVAR_ARCHIVE);
CVAR (Float, stillbob, 0.f, 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); CVAR (String, playerclass, "Fighter", CVAR_USERINFO | CVAR_ARCHIVE);
enum enum
@ -83,6 +84,7 @@ enum
INFO_NeverSwitchOnPickup, INFO_NeverSwitchOnPickup,
INFO_MoveBob, INFO_MoveBob,
INFO_StillBob, INFO_StillBob,
INFO_WBobSpeed,
INFO_PlayerClass, INFO_PlayerClass,
INFO_ColorSet, INFO_ColorSet,
}; };

View file

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

View file

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

View file

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

View file

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

View file

@ -239,6 +239,10 @@ bool AWeapon::HandlePickup (AInventory *item)
{ {
item->ItemFlags |= IF_PICKUPGOOD; 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; return true;
} }
if (Inventory != NULL) if (Inventory != NULL)

View file

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

View file

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

View file

@ -272,6 +272,7 @@ enum
SCRIPT_Return = 15, SCRIPT_Return = 15,
SCRIPT_Event = 16, // [BB] SCRIPT_Event = 16, // [BB]
SCRIPT_Kill = 17, // [JM] SCRIPT_Kill = 17, // [JM]
SCRIPT_Reopen = 18, // [Nash]
}; };
// Script flags // 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. // 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! // [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++) for (int i = 0; i < 2; i++)
{ {
// Bob the weapon based on movement speed. // Bob the weapon based on movement speed. ([SP] And user's bob speed setting)
FAngle angle = (BobSpeed * 35 / TICRATE*(level.time - 1 + i)) * (360.f / 8192.f); 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. // [RH] Smooth transitions between bobbing and not-bobbing frames.
// This also fixes the bug where you can "stick" a weapon off-center by // This also fixes the bug where you can "stick" a weapon off-center by

View file

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

View file

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

View file

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

View file

@ -163,6 +163,7 @@ enum EVMAbortException
X_TOO_MANY_TRIES, X_TOO_MANY_TRIES,
X_ARRAY_OUT_OF_BOUNDS, X_ARRAY_OUT_OF_BOUNDS,
X_DIVISION_BY_ZERO, X_DIVISION_BY_ZERO,
X_BAD_SELF,
}; };
class VMFunction : public DObject 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); col = print_reg(out, 0, a, (mode & MODE_ATYPE) >> MODE_ASHIFT, 24, func);
if ((mode & MODE_BCTYPE) == MODE_BCTHROW) 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) else if ((mode & MODE_BCTYPE) == MODE_BCCATCH)
{ {

View file

@ -616,12 +616,16 @@ begin:
ASSERTA(B); ASSERTA(B);
throw((VMException *)reg.a[B]); throw((VMException *)reg.a[B]);
} }
else else if (a == 1)
{ {
ASSERTKA(B); ASSERTKA(B);
assert(konstatag[B] == ATAG_OBJECT); assert(konstatag[B] == ATAG_OBJECT);
throw((VMException *)konsta[B].o); throw((VMException *)konsta[B].o);
} }
else
{
THROW(BC);
}
NEXTOP; NEXTOP;
OP(CATCH): OP(CATCH):
// This instruction is handled by our own catch handler and should // 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: case X_DIVISION_BY_ZERO:
Printf("division by zero."); Printf("division by zero.");
break; break;
case X_BAD_SELF:
Printf("invalid self pointer.");
break;
} }
Printf("\n"); 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(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(UNTRY, untry, I8), // Pop A entries off the exception stack
xx(THROW, throw, THROW), // A == 0: Throw exception object pB 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 xx(CATCH, catch, CATCH), // A == 0: continue search on next try
// A == 1: continue execution at instruction immediately following CATCH (catches any exception) // 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 // 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_DIMCOLOR = "Dim color";
DSPLYMNU_MOVEBOB = "View bob amount while moving"; DSPLYMNU_MOVEBOB = "View bob amount while moving";
DSPLYMNU_STILLBOB = "View bob amount while not moving"; DSPLYMNU_STILLBOB = "View bob amount while not moving";
DSPLYMNU_BOBSPEED = "Weapon bob speed";
// HUD Options // HUD Options
HUDMNU_TITLE = "HUD Options"; HUDMNU_TITLE = "HUD Options";

View file

@ -690,6 +690,7 @@ OptionMenu "VideoOptions"
ColorPicker "$DSPLYMNU_DIMCOLOR", "dimcolor" ColorPicker "$DSPLYMNU_DIMCOLOR", "dimcolor"
Slider "$DSPLYMNU_MOVEBOB", "movebob", 0, 1.0, 0.05, 2 Slider "$DSPLYMNU_MOVEBOB", "movebob", 0, 1.0, 0.05, 2
Slider "$DSPLYMNU_STILLBOB", "stillbob", 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
} }
//------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------