diff --git a/src/gl/models/gl_voxels.cpp b/src/gl/models/gl_voxels.cpp index 288b1a9db6..6e84bd7abf 100644 --- a/src/gl/models/gl_voxels.cpp +++ b/src/gl/models/gl_voxels.cpp @@ -314,12 +314,12 @@ void FVoxelModel::MakeSlabPolys(int x, int y, kvxslab_t *voxptr, FVoxelMap &chec } if (cull & 4) { - AddFace(x, y, z, x+1, y, z, x, y, z+c, x+1, y, z+c, *col, check); + AddFace(x+1, y, z, x, y, z, x+1, y, z+c, x, y, z+c, *col, check); } if (cull & 8) { - AddFace(x+1, y+1, z, x, y+1, z, x+1, y+1, z+c, x, y+1, z+c, *col, check); - } + AddFace(x, y+1, z, x+1, y+1, z, x, y+1, z+c, x+1, y+1, z+c, *col, check); + } z+=c; col+=c; } diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index 394ca16265..c41e7664f9 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -187,21 +187,18 @@ void GLFlat::DrawSubsector(subsector_t * sub) unsigned int vi[4]; vi[0] = 0; - for (unsigned int i = 1; i < sub->numlines-1; i += 2) + for (unsigned int i = 0; i < sub->numlines - 2; i += 2) { - if (i < sub->numlines - 3) + for (unsigned int j = 1; j < 4; j++) { - for (unsigned int j = 1; j < 4; j++) - { - vi[j] = MIN(i + j, sub->numlines - 1); - } - for (unsigned int x = 0; x < 4; x++) - { - vertex_t *vt = sub->firstline[vi[x]].v1; - qd.Set(x, vt->fX(), plane.plane.ZatPoint(vt) + dz, vt->fY(), vt->fX() / 64.f, -vt->fY() / 64.f); - } - qd.Render(GL_TRIANGLE_FAN); + vi[j] = MIN(i + j, sub->numlines - 1); } + for (unsigned int x = 0; x < 4; x++) + { + vertex_t *vt = sub->firstline[vi[x]].v1; + qd.Set(x, vt->fX(), plane.plane.ZatPoint(vt) + dz, vt->fY(), vt->fX() / 64.f, -vt->fY() / 64.f); + } + qd.Render(GL_TRIANGLE_FAN); } } diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 0225049192..1ebec242ed 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -634,6 +634,7 @@ void AActor::RemoveInventory(AInventory *item) bool AActor::TakeInventory(PClassActor *itemclass, int amount, bool fromdecorate, bool notakeinfinite) { + amount = abs(amount); AInventory *item = FindInventory(itemclass); if (item == NULL) @@ -666,6 +667,7 @@ bool AActor::TakeInventory(PClassActor *itemclass, int amount, bool fromdecorate item->IsKindOf(RUNTIME_CLASS(AAmmo))) { // Nothing to do here, except maybe res = false;? Would it make sense? + result = false; } else if (!amount || amount>=item->Amount) { diff --git a/src/thingdef/thingdef.cpp b/src/thingdef/thingdef.cpp index 41e1e95422..9af031b04f 100644 --- a/src/thingdef/thingdef.cpp +++ b/src/thingdef/thingdef.cpp @@ -480,32 +480,3 @@ void LoadActors () if (!batchrun) Printf("DECORATE parsing took %.2f ms\n", timer.TimeMS()); // Base time: ~52 ms } - - -//========================================================================== -// -// CreateDamageFunction -// -// Creates a damage function suitable for a constant, non-expressioned -// value. -// -//========================================================================== - -VMScriptFunction *CreateDamageFunction(int dmg) -{ - if (dmg == 0) - { - // For zero damage, do not create a function so that the special collision detection case still works as before. - return NULL; - } - else - { - VMFunctionBuilder build; - build.Registers[REGT_POINTER].Get(1); // The self pointer - build.EmitRetInt(0, false, dmg); - build.EmitRetInt(1, true, 0); - VMScriptFunction *sfunc = build.MakeFunction(); - sfunc->NumArgs = 1; - return sfunc; - } -} diff --git a/src/thingdef/thingdef.h b/src/thingdef/thingdef.h index 3a419b112a..565da573af 100644 --- a/src/thingdef/thingdef.h +++ b/src/thingdef/thingdef.h @@ -164,14 +164,6 @@ inline void ResetBaggage (Baggage *bag, PClassActor *stateclass) bag->statedef.MakeStateDefines(stateclass); } -//========================================================================== -// -// Damage function creation -// -//========================================================================== - -VMScriptFunction *CreateDamageFunction(int dmg); - //========================================================================== // // Action function lookup diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index 3b4e6203e6..c6bc8215b0 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -2622,6 +2622,92 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_GiveToSiblings) ACTION_RETURN_INT(count); } +//=========================================================================== +// +// A_SetInventory +// +//=========================================================================== + +DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetInventory) +{ + PARAM_ACTION_PROLOGUE; + PARAM_CLASS(itemtype, AInventory); + PARAM_INT(amount); + PARAM_INT_OPT(ptr) { ptr = AAPTR_DEFAULT; } + PARAM_BOOL_OPT(beyondMax) { beyondMax = false; } + + bool res = false; + + if (itemtype == nullptr) + { + ACTION_RETURN_BOOL(false); + } + + AActor *mobj = COPY_AAPTR(self, ptr); + + if (mobj == nullptr) + { + ACTION_RETURN_BOOL(false); + } + + AInventory *item = mobj->FindInventory(itemtype); + + if (item != nullptr) + { + // A_SetInventory sets the absolute amount. + // Subtract or set the appropriate amount as necessary. + + if (amount == item->Amount) + { + // Nothing was changed. + ACTION_RETURN_BOOL(false); + } + else if (amount <= 0) + { + //Remove it all. + res = (mobj->TakeInventory(itemtype, item->Amount, true, false)); + ACTION_RETURN_BOOL(res); + } + else if (amount < item->Amount) + { + int amt = abs(item->Amount - amount); + res = (mobj->TakeInventory(itemtype, amt, true, false)); + ACTION_RETURN_BOOL(res); + } + else + { + item->Amount = (beyondMax ? amount : clamp(amount, 0, item->MaxAmount)); + ACTION_RETURN_BOOL(true); + } + } + else + { + if (amount <= 0) + { + ACTION_RETURN_BOOL(false); + } + item = static_cast(Spawn(itemtype)); + if (item == nullptr) + { + ACTION_RETURN_BOOL(false); + } + else + { + item->Amount = amount; + item->flags |= MF_DROPPED; + item->ItemFlags |= IF_IGNORESKILL; + item->ClearCounters(); + if (!item->CallTryPickup(mobj)) + { + item->Destroy(); + ACTION_RETURN_BOOL(false); + } + ACTION_RETURN_BOOL(true); + } + } + ACTION_RETURN_BOOL(false); +} + //=========================================================================== // // A_TakeInventory diff --git a/src/win32/hardware.cpp b/src/win32/hardware.cpp index cf39975fd4..da1ced10fa 100644 --- a/src/win32/hardware.cpp +++ b/src/win32/hardware.cpp @@ -69,8 +69,16 @@ FRenderer *gl_CreateInterface(); void I_RestartRenderer(); int currentrenderer = -1; +int currentcanvas = -1; bool changerenderer; +// Software OpenGL canvas +CUSTOM_CVAR(Bool, vid_used3d, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) +{ + if (self != currentcanvas) + Printf("You must restart " GAMENAME " for this change to take effect.\n"); +} + // [ZDoomGL] CUSTOM_CVAR (Int, vid_renderer, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) { @@ -137,13 +145,13 @@ void I_InitGraphics () val.Bool = !!Args->CheckParm ("-devparm"); ticker.SetGenericRepDefault (val, CVAR_Bool); -//#define USE_D3D9_VIDEO -#ifdef USE_D3D9_VIDEO - if (currentrenderer == 1) Video = gl_CreateVideo(); - else Video = new Win32Video(0); -#else - Video = gl_CreateVideo(); -#endif + if (currentcanvas == 1) // Software Canvas: 1 = D3D or DirectDraw, 0 = OpenGL + if (currentrenderer == 1) + Video = gl_CreateVideo(); + else + Video = new Win32Video(0); + else + Video = gl_CreateVideo(); if (Video == NULL) I_FatalError ("Failed to initialize display"); @@ -161,6 +169,7 @@ static void I_DeleteRenderer() void I_CreateRenderer() { currentrenderer = vid_renderer; + currentcanvas = vid_used3d; if (Renderer == NULL) { if (currentrenderer==1) Renderer = gl_CreateInterface(); diff --git a/wadsrc/static/actors/actor.txt b/wadsrc/static/actors/actor.txt index fb6b4c832f..eecc843d39 100644 --- a/wadsrc/static/actors/actor.txt +++ b/wadsrc/static/actors/actor.txt @@ -211,6 +211,7 @@ ACTOR Actor native //: Thinker native state A_JumpIfTargetInsideMeleeRange(state label); native state A_JumpIfInventory(class itemtype, int itemamount, state label, int owner = AAPTR_DEFAULT); native state A_JumpIfArmorType(name Type, state label, int amount = 1); + action native bool A_SetInventory(class itemtype, int amount, int ptr = AAPTR_DEFAULT, bool beyondMax = false); native bool A_GiveInventory(class itemtype, int amount = 0, int giveto = AAPTR_DEFAULT); native bool A_TakeInventory(class itemtype, int amount = 0, int flags = 0, int giveto = AAPTR_DEFAULT); action native bool A_SpawnItem(class itemtype = "Unknown", float distance = 0, float zheight = 0, bool useammo = true, bool transfer_translation = false); diff --git a/wadsrc/static/language.enu b/wadsrc/static/language.enu index a662b719ec..c603864a7a 100644 --- a/wadsrc/static/language.enu +++ b/wadsrc/static/language.enu @@ -2145,6 +2145,12 @@ MODMNU_QUALITY = "Quality"; MODMNU_VOLUMERAMPING = "Volume ramping"; MODMNU_CHIPOMATIC = "Chip-o-matic"; +// Renderer Options +RNDMNU_TITLE = "CHANGE RENDERER"; +RNDMNU_RENDERER = "Hardware Acceleration"; +RNDMNU_TRUECOLOR = "Software Truecolor Mode"; +RNDMNU_CANVAS = "Software Canvas"; + // Video Options VIDMNU_TITLE = "VIDEO MODE"; VIDMNU_FULLSCREEN = "Fullscreen"; @@ -2152,6 +2158,7 @@ VIDMNU_HIDPI = "Retina/HiDPI support"; VIDMNU_ASPECTRATIO = "Aspect ratio"; VIDMNU_FORCEASPECT = "Force aspect ratio"; VIDMNU_5X4ASPECTRATIO = "Enable 5:4 aspect ratio"; +VIDMNU_CHANGERENDER = "Change Rendering Output"; VIDMNU_ENTERTEXT = "Press ENTER to set mode"; VIDMNU_TESTTEXT1 = "T to test mode for 5 seconds"; VIDMNU_TESTTEXT2 = "Please wait 5 seconds..."; @@ -2300,6 +2307,11 @@ OPTVAL_WARNINGS = "Warnings"; OPTVAL_NOTIFICATIONS = "Notifications"; OPTVAL_EVERYTHING = "Everything"; OPTVAL_FULLSCREENONLY = "Fullscreen only"; +OPTVAL_GL = "OpenGL"; +OPTVAL_D3D = "Direct3D"; +OPTVAL_HWPOLY = "OpenGL-Accelerated"; +OPTVAL_SWDOOM = "Doom Software Renderer"; + // Colors C_BRICK = "\cabrick"; C_TAN = "\cbtan"; diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index cbe3fcb970..b26c4c4a56 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -1734,6 +1734,41 @@ OptionMenu ModReplayerOptions // the foo_dumb preferences in foobar2000. } +/*======================================= + * + * Change Renderer Menu + * + *=======================================*/ + +OptionValue "PolyDoom" +{ + 0, "$OPTVAL_SWDOOM" + 1, "$OPTVAL_HWPOLY" +} + +OptionValue "D3DGL" +{ + 0, "$OPTVAL_GL" + 1, "$OPTVAL_D3D" +} + +OptionValue "GLD3D" +{ + 0, "$OPTVAL_D3D" + 1, "$OPTVAL_GL" +} + +OptionMenu RendererMenu +{ + Title "$RNDMNU_TITLE" + Option "$RNDMNU_RENDERER", "vid_renderer", "PolyDoom" + Option "$RNDMNU_TRUECOLOR", "swtruecolor", "OnOff" + IfOption(Windows) + { + Option "$RNDMNU_CANVAS", "vid_used3d", "D3DGL" + } +} + /*======================================= * * Video mode menu @@ -1782,6 +1817,7 @@ OptionMenu VideoModeMenu Option "$VIDMNU_ASPECTRATIO", "menu_screenratios", "Ratios" Option "$VIDMNU_FORCEASPECT", "vid_aspect", "ForceRatios" Option "$VIDMNU_5X4ASPECTRATIO", "vid_tft", "YesNo" + Submenu "$VIDMNU_CHANGERENDER", "RendererMenu" StaticText " " ScreenResolution "res_0" ScreenResolution "res_1"