Skip to content

Commit

Permalink
Merge branch 'master' into isopatch_from_gzdoom_fork
Browse files Browse the repository at this point in the history
  • Loading branch information
dileepvr authored Aug 8, 2024
2 parents ead15a0 + 7930ee8 commit f619942
Show file tree
Hide file tree
Showing 84 changed files with 1,128 additions and 536 deletions.
2 changes: 1 addition & 1 deletion src/am_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2630,7 +2630,7 @@ void DAutomap::drawWalls (bool allmap)
}
else if (line.flags & ML_SECRET)
{ // secret door
if (am_cheat != 0 && line.backsector != nullptr)
if (am_cheat != 0 && am_cheat < 4 && line.backsector != nullptr)
drawMline(&l, AMColors.SecretWallColor);
else
drawMline(&l, AMColors.WallColor);
Expand Down
2 changes: 1 addition & 1 deletion src/common/audio/music/i_music.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ int nomusic = 0;
// Maximum volume of MOD/stream music.
//==========================================================================

CUSTOM_CVARD(Float, snd_musicvolume, 1.0, CVAR_ARCHIVE|CVAR_GLOBALCONFIG, "controls music volume")
CUSTOM_CVARD(Float, snd_musicvolume, 0.65, CVAR_ARCHIVE|CVAR_GLOBALCONFIG, "controls music volume")
{
if (self < 0.f)
self = 0.f;
Expand Down
11 changes: 9 additions & 2 deletions src/common/engine/i_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,15 @@
#include "startupinfo.h"
#include "c_cvars.h"
#include "gstrings.h"
#include "version.h"

static_assert(sizeof(void*) == 8, "32 builds are not supported");
static_assert(sizeof(void*) == 8,
"Only LP64/LLP64 builds are officially supported. "
"Please do not attempt to build for other platforms; "
"even if the program succeeds in a MAP01 smoke test, "
"there are e.g. known visual artifacts "
"<https://forum.zdoom.org/viewtopic.php?f=7&t=75673> "
"that lead to a bad user experience.");

// Some global engine variables taken out of the backend code.
FStartupScreen* StartWindow;
Expand All @@ -23,7 +30,7 @@ bool pauseext;

FStartupInfo GameStartupInfo;

CVAR(Bool, queryiwad, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG);
CVAR(Bool, queryiwad, QUERYIWADDEFAULT, CVAR_ARCHIVE | CVAR_GLOBALCONFIG);
CVAR(String, defaultiwad, "", CVAR_ARCHIVE | CVAR_GLOBALCONFIG);
CVAR(Bool, vid_fps, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)

Expand Down
4 changes: 2 additions & 2 deletions src/common/engine/i_net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -903,11 +903,11 @@ bool JoinGame (int i)
static int PrivateNetOf(in_addr in)
{
int addr = ntohl(in.s_addr);
if ((addr & 0xFFFF0000) == 0xC0A80000) // 192.168.0.0
if ((addr & 0xFFFF0000) == 0xC0A80000) // 192.168.0.0
{
return 0xC0A80000;
}
else if ((addr & 0xFFF00000) == 0xAC100000) // 172.16.0.0
else if ((addr & 0xFFFF0000) >= 0xAC100000 && (addr & 0xFFFF0000) <= 0xAC1F0000) // 172.16.0.0 - 172.31.0.0
{
return 0xAC100000;
}
Expand Down
1 change: 1 addition & 0 deletions src/common/engine/stringtable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ bool FStringTable::ParseLanguageCSV(int filenum, const char* buffer, size_t size
}
}

row[labelcol].StripLeftRight();
FName strName = row[labelcol].GetChars();
if (hasDefaultEntry)
{
Expand Down
2 changes: 1 addition & 1 deletion src/common/filesystem/source/file_directory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ int FDirectory::AddDirectory(const char *dirpath, LumpFilterInfo* filter, FileSy
if (mBasePath == nullptr)
{
// extract the base path from the first entry to cover changes made in ScanDirectory.
auto full = entry.FilePath.find(entry.FilePathRel);
auto full = entry.FilePath.rfind(entry.FilePathRel);
std::string path(entry.FilePath, 0, full);
mBasePath = stringpool->Strdup(path.c_str());
}
Expand Down
2 changes: 1 addition & 1 deletion src/common/menu/menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ static ScaleOverrider *CurrentScaleOverrider;
CVAR (Int, m_showinputgrid, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
CVAR(Bool, m_blockcontrollers, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)

CVAR (Float, snd_menuvolume, 0.6f, CVAR_ARCHIVE)
CVAR (Float, snd_menuvolume, 0.8f, CVAR_ARCHIVE)
CVAR(Int, m_use_mouse, 1, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
CVAR(Int, m_show_backbutton, 0, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
CVAR(Bool, m_cleanscale, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
Expand Down
10 changes: 5 additions & 5 deletions src/common/menu/savegamemanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ int FSavegameManagerBase::RemoveSaveSlot(int index)
int listindex = SaveGames[0]->bNoDelete ? index - 1 : index;
if (listindex < 0) return index;

remove(SaveGames[index]->Filename.GetChars());
RemoveFile(SaveGames[index]->Filename.GetChars());
UnloadSaveData();

FSaveGameNode *file = SaveGames[index];
Expand Down Expand Up @@ -274,7 +274,7 @@ DEFINE_ACTION_FUNCTION(FSavegameManager, DoSave)

unsigned FSavegameManagerBase::ExtractSaveData(int index)
{
FResourceFile *resf;
std::unique_ptr<FResourceFile> resf;
FSaveGameNode *node;

if (index == -1)
Expand All @@ -295,7 +295,7 @@ unsigned FSavegameManagerBase::ExtractSaveData(int index)
(node = SaveGames[index]) &&
!node->Filename.IsEmpty() &&
!node->bOldVersion &&
(resf = FResourceFile::OpenResourceFile(node->Filename.GetChars(), true)) != nullptr)
( (resf.reset(FResourceFile::OpenResourceFile(node->Filename.GetChars(), true))), resf != nullptr))
{
auto info = resf->FindEntry("info.json");
if (info < 0)
Expand All @@ -316,7 +316,8 @@ unsigned FSavegameManagerBase::ExtractSaveData(int index)
auto pic = resf->FindEntry("savepic.png");
if (pic >= 0)
{
FileReader picreader = resf->GetEntryReader(pic, FileSys::READER_NEW, FileSys::READERFLAG_SEEKABLE);
// This must use READER_CACHED or it will lock the savegame file.
FileReader picreader = resf->GetEntryReader(pic, FileSys::READER_CACHED, FileSys::READERFLAG_SEEKABLE);
PNGHandle *png = M_VerifyPNG(picreader);
if (png != nullptr)
{
Expand All @@ -329,7 +330,6 @@ unsigned FSavegameManagerBase::ExtractSaveData(int index)
}
}
}
delete resf;
}
return index;
}
Expand Down
3 changes: 3 additions & 0 deletions src/common/models/voxels.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ struct FVoxelDef
int VoxeldefIndex; // Needed by GZDoom
double Scale;
DAngle AngleOffset;// added to actor's angle to compensate for wrong-facing voxels
double xoffset;
double yoffset;
double zoffset;
bool PitchFromMomentum;
bool UseActorPitch;
bool UseActorRoll;
Expand Down
163 changes: 163 additions & 0 deletions src/common/objects/dobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ void DObject::Destroy ()
}
OnDestroy();
ObjectFlags = (ObjectFlags & ~OF_Fixed) | OF_EuthanizeMe;
GC::WriteBarrier(this);
}

DEFINE_ACTION_FUNCTION(DObject, Destroy)
Expand Down Expand Up @@ -622,3 +623,165 @@ void *DObject::ScriptVar(FName field, PType *type)
// This is only for internal use so I_Error is fine.
I_Error("Variable %s not found in %s\n", field.GetChars(), cls->TypeName.GetChars());
}


//==========================================================================
//
//
//
//==========================================================================

void NetworkEntityManager::InitializeNetworkEntities()
{
if (!s_netEntities.Size())
s_netEntities.AppendFill(nullptr, NetIDStart); // Allocate the first 0-8 slots for the world and clients.
}

// Clients need special handling since they always go in slots 1 - MAXPLAYERS.
void NetworkEntityManager::SetClientNetworkEntity(DObject* mo, const unsigned int playNum)
{
// If resurrecting, we need to swap the corpse's position with the new pawn's
// position so it's no longer considered the client's body.
const uint32_t id = ClientNetIDStart + playNum;
DObject* const oldBody = s_netEntities[id];
if (oldBody != nullptr)
{
if (oldBody == mo)
return;

const uint32_t curID = mo->GetNetworkID();

s_netEntities[curID] = oldBody;
oldBody->ClearNetworkID();
oldBody->SetNetworkID(curID);

mo->ClearNetworkID();
}
else
{
RemoveNetworkEntity(mo); // Free up its current id.
}

s_netEntities[id] = mo;
mo->SetNetworkID(id);
}

void NetworkEntityManager::AddNetworkEntity(DObject* const ent)
{
if (ent->IsNetworked())
return;

// Slot 0 is reserved for the world.
// Clients go in the first 1 - MAXPLAYERS slots
// Everything else is first come first serve.
uint32_t id = WorldNetID;
if (s_openNetIDs.Size())
{
s_openNetIDs.Pop(id);
s_netEntities[id] = ent;
}
else
{
id = s_netEntities.Push(ent);
}

ent->SetNetworkID(id);
}

void NetworkEntityManager::RemoveNetworkEntity(DObject* const ent)
{
if (!ent->IsNetworked())
return;

const uint32_t id = ent->GetNetworkID();
if (id == WorldNetID)
return;

assert(s_netEntities[id] == ent);
if (id >= NetIDStart)
s_openNetIDs.Push(id);
s_netEntities[id] = nullptr;
ent->ClearNetworkID();
}

DObject* NetworkEntityManager::GetNetworkEntity(const uint32_t id)
{
if (id == WorldNetID || id >= s_netEntities.Size())
return nullptr;

return s_netEntities[id];
}

//==========================================================================
//
//
//
//==========================================================================

void DObject::SetNetworkID(const uint32_t id)
{
if (!IsNetworked())
{
ObjectFlags |= OF_Networked;
_networkID = id;
}
}

void DObject::ClearNetworkID()
{
ObjectFlags &= ~OF_Networked;
_networkID = NetworkEntityManager::WorldNetID;
}

void DObject::EnableNetworking(const bool enable)
{
if (enable)
NetworkEntityManager::AddNetworkEntity(this);
else
NetworkEntityManager::RemoveNetworkEntity(this);
}

void DObject::RemoveFromNetwork()
{
NetworkEntityManager::RemoveNetworkEntity(this);
}

static unsigned int GetNetworkID(DObject* const self)
{
return self->GetNetworkID();
}

DEFINE_ACTION_FUNCTION_NATIVE(DObject, GetNetworkID, GetNetworkID)
{
PARAM_SELF_PROLOGUE(DObject);

ACTION_RETURN_INT(self->GetNetworkID());
}

static void EnableNetworking(DObject* const self, const bool enable)
{
self->EnableNetworking(enable);
}

DEFINE_ACTION_FUNCTION_NATIVE(DObject, EnableNetworking, EnableNetworking)
{
PARAM_SELF_PROLOGUE(DObject);
PARAM_BOOL(enable);

self->EnableNetworking(enable);
return 0;
}

static DObject* GetNetworkEntity(const unsigned int id)
{
return NetworkEntityManager::GetNetworkEntity(id);
}

DEFINE_ACTION_FUNCTION_NATIVE(DObject, GetNetworkEntity, GetNetworkEntity)
{
PARAM_PROLOGUE;
PARAM_UINT(id);

ACTION_RETURN_OBJECT(NetworkEntityManager::GetNetworkEntity(id));
}

21 changes: 21 additions & 0 deletions src/common/objects/dobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -487,4 +487,25 @@ inline T *&DObject::PointerVar(FName field)
return *(T**)ScriptVar(field, nullptr); // pointer check is more tricky and for the handful of uses in the DECORATE parser not worth the hassle.
}


class NetworkEntityManager
{
private:
inline static TArray<DObject*> s_netEntities = {};
inline static TArray<uint32_t> s_openNetIDs = {};

public:
NetworkEntityManager() = delete;

static constexpr uint32_t WorldNetID = 0u;
static constexpr uint32_t ClientNetIDStart = 1u;
inline static uint32_t NetIDStart;// = MAXPLAYERS + 1u;

static void InitializeNetworkEntities();
static void SetClientNetworkEntity(DObject* mo, const unsigned int playNum);
static void AddNetworkEntity(DObject* const ent);
static void RemoveNetworkEntity(DObject* const ent);
static DObject* GetNetworkEntity(const uint32_t id);
};

#endif //__DOBJECT_H__
2 changes: 1 addition & 1 deletion src/common/platform/posix/cocoa/i_system.mm
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ void I_ShowFatalError(const char *message)
}


int I_PickIWad(WadStuff* const wads, const int numwads, const bool showwin, const int defaultiwad, int&)
int I_PickIWad(WadStuff* const wads, const int numwads, const bool showwin, const int defaultiwad, int&, FString&)
{
if (!showwin)
{
Expand Down
2 changes: 1 addition & 1 deletion src/common/platform/posix/i_system.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void I_PrintStr (const char *str);
void I_SetIWADInfo ();

// Pick from multiple IWADs to use
int I_PickIWad (WadStuff *wads, int numwads, bool queryiwad, int defaultiwad, int&);
int I_PickIWad (WadStuff *wads, int numwads, bool queryiwad, int defaultiwad, int&, FString &);

// [RH] Checks the registry for Steam's install path, so we can scan its
// directories for IWADs if the user purchased any through Steam.
Expand Down
4 changes: 2 additions & 2 deletions src/common/platform/posix/sdl/i_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ void I_PrintStr(const char *cp)
if (StartWindow) RedrawProgressBar(ProgressBarCurPos,ProgressBarMaxPos);
}

int I_PickIWad (WadStuff *wads, int numwads, bool showwin, int defaultiwad, int& autoloadflags)
int I_PickIWad (WadStuff *wads, int numwads, bool showwin, int defaultiwad, int& autoloadflags, FString &extraArgs)
{
if (!showwin)
{
Expand All @@ -308,7 +308,7 @@ int I_PickIWad (WadStuff *wads, int numwads, bool showwin, int defaultiwad, int&
#ifdef __APPLE__
return I_PickIWad_Cocoa (wads, numwads, showwin, defaultiwad);
#else
return LauncherWindow::ExecModal(wads, numwads, defaultiwad, &autoloadflags);
return LauncherWindow::ExecModal(wads, numwads, defaultiwad, &autoloadflags, &extraArgs);
#endif
}

Expand Down
4 changes: 2 additions & 2 deletions src/common/platform/win32/i_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ static void SetQueryIWad(HWND dialog)
//
//==========================================================================

int I_PickIWad(WadStuff *wads, int numwads, bool showwin, int defaultiwad, int& autoloadflags)
int I_PickIWad(WadStuff *wads, int numwads, bool showwin, int defaultiwad, int& autoloadflags, FString &extraArgs)
{
int vkey;
if (stricmp(queryiwad_key, "shift") == 0)
Expand All @@ -369,7 +369,7 @@ int I_PickIWad(WadStuff *wads, int numwads, bool showwin, int defaultiwad, int&
}
if (showwin || (vkey != 0 && GetAsyncKeyState(vkey)))
{
return LauncherWindow::ExecModal(wads, numwads, defaultiwad, &autoloadflags);
return LauncherWindow::ExecModal(wads, numwads, defaultiwad, &autoloadflags, &extraArgs);
}
return defaultiwad;
}
Expand Down
Loading

0 comments on commit f619942

Please sign in to comment.