mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-23 12:32:34 +00:00
Merge branch 'master' of https://github.com/rheit/zdoom
Conflicts: src/version.h
This commit is contained in:
commit
daf5b97ff9
33 changed files with 1075 additions and 464 deletions
|
@ -740,6 +740,7 @@ add_executable( zdoom WIN32
|
||||||
m_misc.cpp
|
m_misc.cpp
|
||||||
m_png.cpp
|
m_png.cpp
|
||||||
m_random.cpp
|
m_random.cpp
|
||||||
|
m_specialpaths.cpp
|
||||||
memarena.cpp
|
memarena.cpp
|
||||||
md5.cpp
|
md5.cpp
|
||||||
name.cpp
|
name.cpp
|
||||||
|
|
|
@ -334,11 +334,12 @@ enum
|
||||||
MF6_NOTONAUTOMAP = 0x40000000, // will not be shown on automap with the 'scanner' powerup.
|
MF6_NOTONAUTOMAP = 0x40000000, // will not be shown on automap with the 'scanner' powerup.
|
||||||
MF6_RELATIVETOFLOOR = 0x80000000, // [RC] Make flying actors be affected by lifts.
|
MF6_RELATIVETOFLOOR = 0x80000000, // [RC] Make flying actors be affected by lifts.
|
||||||
|
|
||||||
// --- mobj.flags6 ---
|
// --- mobj.flags7 ---
|
||||||
|
|
||||||
MF7_NEVERTARGET = 0x00000001, // can not be targetted at all, even if monster friendliness is considered.
|
MF7_NEVERTARGET = 0x00000001, // can not be targetted at all, even if monster friendliness is considered.
|
||||||
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
|
||||||
|
|
||||||
// --- mobj.renderflags ---
|
// --- mobj.renderflags ---
|
||||||
|
|
||||||
|
|
|
@ -505,31 +505,13 @@ bool FCajunMaster::LoadBots ()
|
||||||
bool gotteam = false;
|
bool gotteam = false;
|
||||||
|
|
||||||
bglobal.ForgetBots ();
|
bglobal.ForgetBots ();
|
||||||
#ifndef __unix__
|
tmp = M_GetCajunPath(BOTFILENAME);
|
||||||
tmp = progdir;
|
if (tmp.IsEmpty())
|
||||||
tmp += "zcajun/" BOTFILENAME;
|
|
||||||
if (!FileExists (tmp))
|
|
||||||
{
|
{
|
||||||
DPrintf ("No " BOTFILENAME ", so no bots\n");
|
DPrintf ("No " BOTFILENAME ", so no bots\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#else
|
sc.OpenFile(tmp);
|
||||||
tmp = GetUserFile (BOTFILENAME);
|
|
||||||
if (!FileExists (tmp))
|
|
||||||
{
|
|
||||||
if (!FileExists (SHARE_DIR BOTFILENAME))
|
|
||||||
{
|
|
||||||
DPrintf ("No " BOTFILENAME ", so no bots\n");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
sc.OpenFile (SHARE_DIR BOTFILENAME);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sc.OpenFile (tmp);
|
|
||||||
}
|
|
||||||
|
|
||||||
while (sc.GetString ())
|
while (sc.GetString ())
|
||||||
{
|
{
|
||||||
|
|
|
@ -2137,17 +2137,6 @@ static void CheckCmdLine()
|
||||||
Printf ("%s", GStrings("D_DEVSTR"));
|
Printf ("%s", GStrings("D_DEVSTR"));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(__unix__) && !defined(__APPLE__)
|
|
||||||
// We do not need to support -cdrom under Unix, because all the files
|
|
||||||
// that would go to c:\\zdoomdat are already stored in .zdoom inside
|
|
||||||
// the user's home directory.
|
|
||||||
if (Args->CheckParm("-cdrom"))
|
|
||||||
{
|
|
||||||
Printf ("%s", GStrings("D_CDROM"));
|
|
||||||
mkdir (CDROM_DIR, 0);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// turbo option // [RH] (now a cvar)
|
// turbo option // [RH] (now a cvar)
|
||||||
v = Args->CheckValue("-turbo");
|
v = Args->CheckValue("-turbo");
|
||||||
if (v != NULL)
|
if (v != NULL)
|
||||||
|
|
|
@ -1058,4 +1058,5 @@ userinfo_t::~userinfo_t()
|
||||||
{
|
{
|
||||||
delete pair->Value;
|
delete pair->Value;
|
||||||
}
|
}
|
||||||
|
this->Clear();
|
||||||
}
|
}
|
||||||
|
|
|
@ -325,6 +325,10 @@ struct userinfo_t : TMap<FName,FBaseCVar *>
|
||||||
{
|
{
|
||||||
return *static_cast<FIntCVar *>(*CheckKey(NAME_Gender));
|
return *static_cast<FIntCVar *>(*CheckKey(NAME_Gender));
|
||||||
}
|
}
|
||||||
|
bool GetNoAutostartMap() const
|
||||||
|
{
|
||||||
|
return *static_cast<FBoolCVar *>(*CheckKey(NAME_Wi_NoAutostartMap));
|
||||||
|
}
|
||||||
|
|
||||||
void Reset();
|
void Reset();
|
||||||
int TeamChanged(int team);
|
int TeamChanged(int team);
|
||||||
|
@ -348,6 +352,7 @@ class player_t
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
player_t();
|
player_t();
|
||||||
|
player_t &operator= (const player_t &p);
|
||||||
|
|
||||||
void Serialize (FArchive &arc);
|
void Serialize (FArchive &arc);
|
||||||
size_t FixPointers (const DObject *obj, DObject *replacement);
|
size_t FixPointers (const DObject *obj, DObject *replacement);
|
||||||
|
|
|
@ -473,7 +473,7 @@ public:
|
||||||
// use this method.
|
// use this method.
|
||||||
virtual size_t PointerSubstitution (DObject *old, DObject *notOld);
|
virtual size_t PointerSubstitution (DObject *old, DObject *notOld);
|
||||||
static size_t StaticPointerSubstitution (DObject *old, DObject *notOld);
|
static size_t StaticPointerSubstitution (DObject *old, DObject *notOld);
|
||||||
|
|
||||||
PClass *GetClass() const
|
PClass *GetClass() const
|
||||||
{
|
{
|
||||||
if (Class == NULL)
|
if (Class == NULL)
|
||||||
|
|
|
@ -457,7 +457,7 @@ int DThinker::TickThinkers (FThinkerList *list, FThinkerList *dest)
|
||||||
node->PostBeginPlay();
|
node->PostBeginPlay();
|
||||||
}
|
}
|
||||||
else if (dest != NULL)
|
else if (dest != NULL)
|
||||||
{ // Move thinker from this list to the destination list
|
{
|
||||||
I_Error("There is a thinker in the fresh list that has already ticked.\n");
|
I_Error("There is a thinker in the fresh list that has already ticked.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Punch)
|
||||||
angle += pr_punch.Random2() << 18;
|
angle += pr_punch.Random2() << 18;
|
||||||
pitch = P_AimLineAttack (self, angle, MELEERANGE, &linetarget);
|
pitch = P_AimLineAttack (self, angle, MELEERANGE, &linetarget);
|
||||||
|
|
||||||
P_LineAttack (self, angle, MELEERANGE, pitch, damage, NAME_Melee, NAME_BulletPuff, true, &linetarget);
|
P_LineAttack (self, angle, MELEERANGE, pitch, damage, NAME_Melee, NAME_BulletPuff, LAF_ISMELEEATTACK, &linetarget);
|
||||||
|
|
||||||
// turn to face target
|
// turn to face target
|
||||||
if (linetarget)
|
if (linetarget)
|
||||||
|
|
|
@ -1919,32 +1919,10 @@ FString G_BuildSaveName (const char *prefix, int slot)
|
||||||
leader = Args->CheckValue ("-savedir");
|
leader = Args->CheckValue ("-savedir");
|
||||||
if (leader.IsEmpty())
|
if (leader.IsEmpty())
|
||||||
{
|
{
|
||||||
#if !defined(__unix__) && !defined(__APPLE__)
|
leader = save_dir;
|
||||||
if (Args->CheckParm ("-cdrom"))
|
|
||||||
{
|
|
||||||
leader = CDROM_DIR "/";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
leader = save_dir;
|
|
||||||
}
|
|
||||||
if (leader.IsEmpty())
|
if (leader.IsEmpty())
|
||||||
{
|
{
|
||||||
#ifdef __unix__
|
leader = M_GetSavegamesPath();
|
||||||
leader = "~/" GAME_DIR;
|
|
||||||
#elif defined(__APPLE__)
|
|
||||||
char cpath[PATH_MAX];
|
|
||||||
FSRef folder;
|
|
||||||
|
|
||||||
if (noErr == FSFindFolder(kUserDomain, kDocumentsFolderType, kCreateFolder, &folder) &&
|
|
||||||
noErr == FSRefMakePath(&folder, (UInt8*)cpath, PATH_MAX))
|
|
||||||
{
|
|
||||||
leader << cpath << "/" GAME_DIR "/Savegames/";
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
leader = progdir;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
size_t len = leader.Len();
|
size_t len = leader.Len();
|
||||||
|
|
|
@ -38,6 +38,7 @@ class ACustomBridge : public AActor
|
||||||
DECLARE_CLASS (ACustomBridge, AActor)
|
DECLARE_CLASS (ACustomBridge, AActor)
|
||||||
public:
|
public:
|
||||||
void BeginPlay ();
|
void BeginPlay ();
|
||||||
|
void Destroy();
|
||||||
};
|
};
|
||||||
|
|
||||||
IMPLEMENT_CLASS(ACustomBridge)
|
IMPLEMENT_CLASS(ACustomBridge)
|
||||||
|
@ -58,6 +59,25 @@ void ACustomBridge::BeginPlay ()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ACustomBridge::Destroy()
|
||||||
|
{
|
||||||
|
// Hexen originally just set a flag to make the bridge balls remove themselves in A_BridgeOrbit.
|
||||||
|
// But this is not safe with custom bridge balls that do not necessarily call that function.
|
||||||
|
// So the best course of action is to look for all bridge balls here and destroy them ourselves.
|
||||||
|
|
||||||
|
TThinkerIterator<AActor> it;
|
||||||
|
AActor *thing;
|
||||||
|
|
||||||
|
while ((thing = it.Next()))
|
||||||
|
{
|
||||||
|
if (thing->target == this)
|
||||||
|
{
|
||||||
|
thing->Destroy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Super::Destroy();
|
||||||
|
}
|
||||||
|
|
||||||
// Action functions for the non-Doom bridge --------------------------------
|
// Action functions for the non-Doom bridge --------------------------------
|
||||||
|
|
||||||
#define ORBIT_RADIUS 15
|
#define ORBIT_RADIUS 15
|
||||||
|
@ -89,10 +109,6 @@ DEFINE_ACTION_FUNCTION(AActor, A_BridgeOrbit)
|
||||||
// Set rotation radius
|
// Set rotation radius
|
||||||
if (self->target->args[4]) rotationradius = ((self->target->args[4] * self->target->radius) / (100 * FRACUNIT));
|
if (self->target->args[4]) rotationradius = ((self->target->args[4] * self->target->radius) / (100 * FRACUNIT));
|
||||||
|
|
||||||
if (self->target->special1)
|
|
||||||
{
|
|
||||||
self->SetState (NULL);
|
|
||||||
}
|
|
||||||
self->angle += rotationspeed;
|
self->angle += rotationspeed;
|
||||||
self->x = self->target->x + rotationradius * finecosine[self->angle >> ANGLETOFINESHIFT];
|
self->x = self->target->x + rotationradius * finecosine[self->angle >> ANGLETOFINESHIFT];
|
||||||
self->y = self->target->y + rotationradius * finesine[self->angle >> ANGLETOFINESHIFT];
|
self->y = self->target->y + rotationradius * finesine[self->angle >> ANGLETOFINESHIFT];
|
||||||
|
@ -115,7 +131,6 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_BridgeInit)
|
||||||
cy = self->y;
|
cy = self->y;
|
||||||
cz = self->z;
|
cz = self->z;
|
||||||
startangle = pr_orbit() << 24;
|
startangle = pr_orbit() << 24;
|
||||||
self->special1 = 0;
|
|
||||||
|
|
||||||
// Spawn triad into world -- may be more than a triad now.
|
// Spawn triad into world -- may be more than a triad now.
|
||||||
int ballcount = self->args[2]==0 ? 3 : self->args[2];
|
int ballcount = self->args[2]==0 ? 3 : self->args[2];
|
||||||
|
@ -129,14 +144,6 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_BridgeInit)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* never used
|
|
||||||
void A_BridgeRemove (AActor *self)
|
|
||||||
{
|
|
||||||
self->special1 = true; // Removing the bridge
|
|
||||||
self->flags &= ~MF_SOLID;
|
|
||||||
self->SetState (&ABridge::States[S_FREE_BRIDGE]);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Invisible bridge --------------------------------------------------------
|
// Invisible bridge --------------------------------------------------------
|
||||||
|
|
||||||
|
|
|
@ -444,6 +444,20 @@ void ST_LoadCrosshair(bool alwaysload=false);
|
||||||
void ST_Clear();
|
void ST_Clear();
|
||||||
extern FTexture *CrosshairImage;
|
extern FTexture *CrosshairImage;
|
||||||
|
|
||||||
FTextureID GetWeaponIcon(AWeapon *weapon);
|
FTextureID GetInventoryIcon(AInventory *item, DWORD flags, bool *applyscale);
|
||||||
|
|
||||||
|
enum DI_Flags
|
||||||
|
{
|
||||||
|
DI_SKIPICON = 0x1,
|
||||||
|
DI_SKIPALTICON = 0x2,
|
||||||
|
DI_SKIPSPAWN = 0x4,
|
||||||
|
DI_SKIPREADY = 0x8,
|
||||||
|
DI_ALTICONFIRST = 0x10,
|
||||||
|
|
||||||
|
DI_DRAWINBOX = 0x20, // Set when either width or height is not zero
|
||||||
|
|
||||||
|
DI_FORCESCALE = 0x40,
|
||||||
|
DI_ALTERNATEONFAIL = 0x80
|
||||||
|
};
|
||||||
|
|
||||||
#endif /* __SBAR_H__ */
|
#endif /* __SBAR_H__ */
|
||||||
|
|
|
@ -1187,8 +1187,12 @@ public:
|
||||||
|
|
||||||
if((offsetflags & SBarInfoCommand::CENTER) == SBarInfoCommand::CENTER)
|
if((offsetflags & SBarInfoCommand::CENTER) == SBarInfoCommand::CENTER)
|
||||||
{
|
{
|
||||||
dx -= (texture->GetScaledWidthDouble()/2.0)-texture->GetScaledLeftOffsetDouble();
|
if (forceWidth < 0) dx -= (texture->GetScaledWidthDouble()/2.0)-texture->GetScaledLeftOffsetDouble();
|
||||||
dy -= (texture->GetScaledHeightDouble()/2.0)-texture->GetScaledTopOffsetDouble();
|
else dx -= forceWidth*(0.5-(texture->GetScaledLeftOffsetDouble()/texture->GetScaledWidthDouble()));
|
||||||
|
//Unoptimalized formula is dx -= forceWidth/2.0-(texture->GetScaledLeftOffsetDouble()*forceWidth/texture->GetScaledWidthDouble());
|
||||||
|
|
||||||
|
if (forceHeight < 0) dy -= (texture->GetScaledHeightDouble()/2.0)-texture->GetScaledTopOffsetDouble();
|
||||||
|
else dy -= forceHeight*(0.5-(texture->GetScaledTopOffsetDouble()/texture->GetScaledHeightDouble()));
|
||||||
}
|
}
|
||||||
|
|
||||||
dx += xOffset;
|
dx += xOffset;
|
||||||
|
|
|
@ -41,28 +41,65 @@
|
||||||
// classes.
|
// classes.
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
class CommandDrawImage : public SBarInfoCommandFlowControl
|
||||||
class CommandDrawImage : public SBarInfoCommand
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CommandDrawImage(SBarInfo *script) : SBarInfoCommand(script),
|
CommandDrawImage(SBarInfo *script) : SBarInfoCommandFlowControl(script),
|
||||||
translatable(false), type(NORMAL_IMAGE), image(-1), offset(static_cast<Offset> (TOP|LEFT)),
|
translatable(false), type(NORMAL_IMAGE), image(-1), maxwidth(-1),
|
||||||
|
maxheight(-1), spawnScaleX(1.0f), spawnScaleY(1.0f), flags(0),
|
||||||
|
applyscale(false), offset(static_cast<Offset> (TOP|LEFT)),
|
||||||
texture(NULL), alpha(FRACUNIT)
|
texture(NULL), alpha(FRACUNIT)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void Draw(const SBarInfoMainBlock *block, const DSBarInfo *statusBar)
|
void Draw(const SBarInfoMainBlock *block, const DSBarInfo *statusBar)
|
||||||
{
|
{
|
||||||
|
if(flags & DI_ALTERNATEONFAIL)
|
||||||
|
SBarInfoCommandFlowControl::Draw(block, statusBar);
|
||||||
|
|
||||||
if(texture == NULL)
|
if(texture == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
int w = maxwidth, h = maxheight;
|
||||||
|
|
||||||
// We must calculate this per frame in order to prevent glitches with cl_capfps true.
|
// We must calculate this per frame in order to prevent glitches with cl_capfps true.
|
||||||
fixed_t frameAlpha = block->Alpha();
|
fixed_t frameAlpha = block->Alpha();
|
||||||
if(alpha != FRACUNIT)
|
if(alpha != FRACUNIT)
|
||||||
frameAlpha = fixed_t(((double) block->Alpha() / (double) FRACUNIT) * ((double) alpha / (double) OPAQUE) * FRACUNIT);
|
frameAlpha = fixed_t(((double) block->Alpha() / (double) FRACUNIT) * ((double) alpha / (double) OPAQUE) * FRACUNIT);
|
||||||
|
|
||||||
|
if(flags & DI_DRAWINBOX)
|
||||||
|
{
|
||||||
|
double scale1, scale2;
|
||||||
|
scale1 = scale2 = 1.0f;
|
||||||
|
double texwidth = (int) (texture->GetScaledWidthDouble()*spawnScaleX);
|
||||||
|
double texheight = (int) (texture->GetScaledHeightDouble()*spawnScaleY);
|
||||||
|
|
||||||
|
if (w != -1 && (w<texwidth || (flags & DI_FORCESCALE)))
|
||||||
|
{
|
||||||
|
scale1 = w/texwidth;
|
||||||
|
}
|
||||||
|
if (h != -1 && (h<texheight || (flags & DI_FORCESCALE)))
|
||||||
|
{
|
||||||
|
scale2 = h/texheight;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flags & DI_FORCESCALE)
|
||||||
|
{
|
||||||
|
if (w == -1 || (h != -1 && scale2<scale1))
|
||||||
|
scale1=scale2;
|
||||||
|
}
|
||||||
|
else if (scale2<scale1) scale1=scale2;
|
||||||
|
|
||||||
|
w=(int)(texwidth*scale1);
|
||||||
|
h=(int)(texheight*scale1);
|
||||||
|
}
|
||||||
|
else if (applyscale)
|
||||||
|
{
|
||||||
|
w=(int) (texture->GetScaledWidthDouble()*spawnScaleX);
|
||||||
|
h=(int) (texture->GetScaledHeightDouble()*spawnScaleY);
|
||||||
|
}
|
||||||
statusBar->DrawGraphic(texture, imgx, imgy, block->XOffset(), block->YOffset(), frameAlpha, block->FullScreenOffsets(),
|
statusBar->DrawGraphic(texture, imgx, imgy, block->XOffset(), block->YOffset(), frameAlpha, block->FullScreenOffsets(),
|
||||||
translatable, false, offset);
|
translatable, false, offset, false, w, h);
|
||||||
}
|
}
|
||||||
void Parse(FScanner &sc, bool fullScreenOffsets)
|
void Parse(FScanner &sc, bool fullScreenOffsets)
|
||||||
{
|
{
|
||||||
|
@ -98,7 +135,7 @@ class CommandDrawImage : public SBarInfoCommand
|
||||||
type = HEXENARMOR_AMULET;
|
type = HEXENARMOR_AMULET;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sc.ScriptMessage("Unkown armor type: '%s'", sc.String);
|
sc.ScriptMessage("Unknown armor type: '%s'", sc.String);
|
||||||
type = HEXENARMOR_ARMOR;
|
type = HEXENARMOR_ARMOR;
|
||||||
}
|
}
|
||||||
sc.MustGetToken(',');
|
sc.MustGetToken(',');
|
||||||
|
@ -141,48 +178,90 @@ class CommandDrawImage : public SBarInfoCommand
|
||||||
offset = CENTER;
|
offset = CENTER;
|
||||||
else if(sc.Compare("centerbottom"))
|
else if(sc.Compare("centerbottom"))
|
||||||
offset = static_cast<Offset> (HMIDDLE|BOTTOM);
|
offset = static_cast<Offset> (HMIDDLE|BOTTOM);
|
||||||
else
|
else if(!sc.Compare("lefttop")) //That's already set
|
||||||
sc.ScriptError("'%s' is not a valid alignment.", sc.String);
|
sc.ScriptError("'%s' is not a valid alignment.", sc.String);
|
||||||
}
|
}
|
||||||
sc.MustGetToken(';');
|
if(sc.CheckToken(','))
|
||||||
|
{
|
||||||
|
sc.MustGetToken(TK_IntConst);
|
||||||
|
if((maxwidth = sc.Number) > 0)
|
||||||
|
flags |= DI_DRAWINBOX;
|
||||||
|
else
|
||||||
|
maxwidth = -1;
|
||||||
|
sc.MustGetToken(',');
|
||||||
|
sc.MustGetToken(TK_IntConst);
|
||||||
|
if ((maxheight = sc.Number) > 0)
|
||||||
|
flags |= DI_DRAWINBOX;
|
||||||
|
else
|
||||||
|
maxheight = -1;
|
||||||
|
}
|
||||||
|
if(sc.CheckToken(','))
|
||||||
|
{
|
||||||
|
while(sc.CheckToken(TK_Identifier))
|
||||||
|
{
|
||||||
|
if(sc.Compare("skipicon"))
|
||||||
|
flags |= DI_SKIPICON;
|
||||||
|
else if(sc.Compare("skipalticon"))
|
||||||
|
flags |= DI_SKIPALTICON;
|
||||||
|
else if(sc.Compare("skipspawn"))
|
||||||
|
flags |= DI_SKIPSPAWN;
|
||||||
|
else if(sc.Compare("skipready"))
|
||||||
|
flags |= DI_SKIPREADY;
|
||||||
|
else if(sc.Compare("alticonfirst"))
|
||||||
|
flags |= DI_ALTICONFIRST;
|
||||||
|
else if(sc.Compare("forcescale"))
|
||||||
|
{
|
||||||
|
if(flags & DI_DRAWINBOX)
|
||||||
|
flags |= DI_FORCESCALE;
|
||||||
|
}
|
||||||
|
else if(sc.Compare("alternateonfail"))
|
||||||
|
flags |= DI_ALTERNATEONFAIL;
|
||||||
|
else
|
||||||
|
sc.ScriptError("Unknown flag '%s'.", sc.String);
|
||||||
|
if(!sc.CheckToken('|') && !sc.CheckToken(',')) break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(flags & DI_ALTERNATEONFAIL)
|
||||||
|
SBarInfoCommandFlowControl::Parse(sc, fullScreenOffsets);
|
||||||
|
else
|
||||||
|
sc.MustGetToken(';');
|
||||||
}
|
}
|
||||||
void Tick(const SBarInfoMainBlock *block, const DSBarInfo *statusBar, bool hudChanged)
|
void Tick(const SBarInfoMainBlock *block, const DSBarInfo *statusBar, bool hudChanged)
|
||||||
{
|
{
|
||||||
|
SBarInfoCommandFlowControl::Tick(block, statusBar, hudChanged);
|
||||||
|
|
||||||
texture = NULL;
|
texture = NULL;
|
||||||
alpha = FRACUNIT;
|
alpha = FRACUNIT;
|
||||||
|
if (applyscale)
|
||||||
|
{
|
||||||
|
spawnScaleX = spawnScaleY = 1.0f;
|
||||||
|
applyscale = false;
|
||||||
|
}
|
||||||
if(type == PLAYERICON)
|
if(type == PLAYERICON)
|
||||||
texture = TexMan[statusBar->CPlayer->mo->ScoreIcon];
|
texture = TexMan[statusBar->CPlayer->mo->ScoreIcon];
|
||||||
else if(type == AMMO1)
|
else if(type == AMMO1)
|
||||||
{
|
{
|
||||||
if(statusBar->ammo1 != NULL)
|
AAmmo *ammo = statusBar->ammo1;
|
||||||
texture = TexMan[statusBar->ammo1->Icon];
|
if(ammo != NULL)
|
||||||
|
GetIcon(ammo);
|
||||||
}
|
}
|
||||||
else if(type == AMMO2)
|
else if(type == AMMO2)
|
||||||
{
|
{
|
||||||
if(statusBar->ammo2 != NULL)
|
AAmmo *ammo = statusBar->ammo2;
|
||||||
texture = TexMan[statusBar->ammo2->Icon];
|
if(ammo != NULL)
|
||||||
|
GetIcon(ammo);
|
||||||
}
|
}
|
||||||
else if(type == ARMOR)
|
else if(type == ARMOR)
|
||||||
{
|
{
|
||||||
if(statusBar->armor != NULL && statusBar->armor->Amount != 0)
|
ABasicArmor *armor = statusBar->armor;
|
||||||
texture = TexMan(statusBar->armor->Icon);
|
if(armor != NULL && armor->Amount != 0)
|
||||||
|
GetIcon(armor);
|
||||||
}
|
}
|
||||||
else if(type == WEAPONICON)
|
else if(type == WEAPONICON)
|
||||||
{
|
{
|
||||||
AWeapon *weapon = statusBar->CPlayer->ReadyWeapon;
|
AWeapon *weapon = statusBar->CPlayer->ReadyWeapon;
|
||||||
if(weapon != NULL)
|
if(weapon != NULL)
|
||||||
{
|
GetIcon(weapon);
|
||||||
FTextureID icon;
|
|
||||||
if (weapon->Icon.isValid())
|
|
||||||
{
|
|
||||||
icon = weapon->Icon;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
icon = GetWeaponIcon(weapon);
|
|
||||||
}
|
|
||||||
texture = TexMan[icon];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if(type == SIGIL)
|
else if(type == SIGIL)
|
||||||
{
|
{
|
||||||
|
@ -213,8 +292,26 @@ class CommandDrawImage : public SBarInfoCommand
|
||||||
texture = TexMan(statusBar->CPlayer->mo->InvSel->Icon);
|
texture = TexMan(statusBar->CPlayer->mo->InvSel->Icon);
|
||||||
else if(image >= 0)
|
else if(image >= 0)
|
||||||
texture = statusBar->Images[image];
|
texture = statusBar->Images[image];
|
||||||
|
|
||||||
|
if (flags & DI_ALTERNATEONFAIL)
|
||||||
|
{
|
||||||
|
SetTruth(texture == NULL || !(texture->GetID().isValid()), block, statusBar);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
protected:
|
protected:
|
||||||
|
void GetIcon(AInventory *item)
|
||||||
|
{
|
||||||
|
FTextureID icon = GetInventoryIcon(item, flags, &applyscale);
|
||||||
|
|
||||||
|
if (applyscale)
|
||||||
|
{
|
||||||
|
spawnScaleX = FIXED2FLOAT(item->scaleX);
|
||||||
|
spawnScaleY = FIXED2FLOAT(item->scaleY);
|
||||||
|
}
|
||||||
|
|
||||||
|
texture = TexMan[icon];
|
||||||
|
}
|
||||||
|
|
||||||
enum ImageType
|
enum ImageType
|
||||||
{
|
{
|
||||||
PLAYERICON,
|
PLAYERICON,
|
||||||
|
@ -238,6 +335,12 @@ class CommandDrawImage : public SBarInfoCommand
|
||||||
ImageType type;
|
ImageType type;
|
||||||
int image;
|
int image;
|
||||||
FTextureID sprite;
|
FTextureID sprite;
|
||||||
|
int maxwidth;
|
||||||
|
int maxheight;
|
||||||
|
double spawnScaleX;
|
||||||
|
double spawnScaleY;
|
||||||
|
DWORD flags;
|
||||||
|
bool applyscale; //Set remotely from from GetInventoryIcon when selected sprite comes from Spawn state
|
||||||
// I'm using imgx/imgy here so that I can inherit drawimage with drawnumber for some commands.
|
// I'm using imgx/imgy here so that I can inherit drawimage with drawnumber for some commands.
|
||||||
SBarInfoCoordinate imgx;
|
SBarInfoCoordinate imgx;
|
||||||
SBarInfoCoordinate imgy;
|
SBarInfoCoordinate imgy;
|
||||||
|
@ -1479,11 +1582,11 @@ class CommandDrawMugShot : public SBarInfoCommand
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
class CommandDrawSelectedInventory : public SBarInfoCommandFlowControl, private CommandDrawImage, private CommandDrawNumber
|
class CommandDrawSelectedInventory : public CommandDrawImage, private CommandDrawNumber
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CommandDrawSelectedInventory(SBarInfo *script) : SBarInfoCommandFlowControl(script),
|
CommandDrawSelectedInventory(SBarInfo *script) : CommandDrawImage(script),
|
||||||
CommandDrawImage(script), CommandDrawNumber(script), alternateOnEmpty(false),
|
CommandDrawNumber(script), alternateOnEmpty(false),
|
||||||
artiflash(false), alwaysShowCounter(false)
|
artiflash(false), alwaysShowCounter(false)
|
||||||
{
|
{
|
||||||
length = INT_MAX; // Counter size
|
length = INT_MAX; // Counter size
|
||||||
|
@ -3011,7 +3114,7 @@ class CommandDrawGem : public SBarInfoCommand
|
||||||
else
|
else
|
||||||
sc.ScriptError("Unknown drawgem flag '%s'.", sc.String);
|
sc.ScriptError("Unknown drawgem flag '%s'.", sc.String);
|
||||||
if(!sc.CheckToken('|'))
|
if(!sc.CheckToken('|'))
|
||||||
sc.MustGetToken(',');
|
sc.MustGetToken(',');
|
||||||
}
|
}
|
||||||
sc.MustGetToken(TK_StringConst); //chain
|
sc.MustGetToken(TK_StringConst); //chain
|
||||||
chain = script->newImage(sc.String);
|
chain = script->newImage(sc.String);
|
||||||
|
|
|
@ -135,12 +135,12 @@ static void DrawImageToBox(FTexture * tex, int x, int y, int w, int h, int trans
|
||||||
|
|
||||||
if (tex)
|
if (tex)
|
||||||
{
|
{
|
||||||
int texwidth=tex->GetWidth();
|
double texwidth=tex->GetScaledWidthDouble();
|
||||||
int texheight=tex->GetHeight();
|
double texheight=tex->GetScaledHeightDouble();
|
||||||
|
|
||||||
if (w<texwidth) scale1=(double)w/texwidth;
|
if (w<texwidth) scale1=w/texwidth;
|
||||||
else scale1=1.0f;
|
else scale1=1.0f;
|
||||||
if (h<texheight) scale2=(double)h/texheight;
|
if (h<texheight) scale2=h/texheight;
|
||||||
else scale2=1.0f;
|
else scale2=1.0f;
|
||||||
if (scale2<scale1) scale1=scale2;
|
if (scale2<scale1) scale1=scale2;
|
||||||
|
|
||||||
|
@ -606,22 +606,40 @@ static int DrawAmmo(player_t *CPlayer, int x, int y)
|
||||||
// Weapons List
|
// Weapons List
|
||||||
//
|
//
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
FTextureID GetInventoryIcon(AInventory *item, DWORD flags, bool *applyscale=NULL) // This function is also used by SBARINFO
|
||||||
FTextureID GetWeaponIcon(AWeapon *weapon) // This function is also used by SBARINFO
|
|
||||||
{
|
{
|
||||||
FTextureID AltIcon = GetHUDIcon(weapon->GetClass());
|
FTextureID picnum, AltIcon = GetHUDIcon(item->GetClass());
|
||||||
FState * state=NULL, *ReadyState;
|
FState * state=NULL, *ReadyState;
|
||||||
|
|
||||||
FTextureID picnum = !AltIcon.isNull()? AltIcon : weapon->Icon;
|
picnum.SetNull();
|
||||||
|
if (flags & DI_ALTICONFIRST)
|
||||||
if (picnum.isNull())
|
|
||||||
{
|
{
|
||||||
if (weapon->SpawnState && weapon->SpawnState->sprite!=0)
|
if (!(flags & DI_SKIPALTICON) && AltIcon.isValid())
|
||||||
|
picnum = AltIcon;
|
||||||
|
else if (!(flags & DI_SKIPICON))
|
||||||
|
picnum = item->Icon;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!(flags & DI_SKIPICON) && item->Icon.isValid())
|
||||||
|
picnum = item->Icon;
|
||||||
|
else if (!(flags & DI_SKIPALTICON))
|
||||||
|
picnum = AltIcon;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!picnum.isValid()) //isNull() is bad for checking, because picnum could be also invalid (-1)
|
||||||
|
{
|
||||||
|
if (!(flags & DI_SKIPSPAWN) && item->SpawnState && item->SpawnState->sprite!=0)
|
||||||
{
|
{
|
||||||
state = weapon->SpawnState;
|
state = item->SpawnState;
|
||||||
|
|
||||||
|
if (applyscale != NULL && !(flags & DI_FORCESCALE))
|
||||||
|
{
|
||||||
|
*applyscale = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// no spawn state - now try the ready state
|
// no spawn state - now try the ready state if it's weapon
|
||||||
else if ((ReadyState = weapon->FindState(NAME_Ready)) && ReadyState->sprite!=0)
|
else if (!(flags & DI_SKIPREADY) && item->GetClass()->IsDescendantOf(RUNTIME_CLASS(AWeapon)) && (ReadyState = item->FindState(NAME_Ready)) && ReadyState->sprite!=0)
|
||||||
{
|
{
|
||||||
state = ReadyState;
|
state = ReadyState;
|
||||||
}
|
}
|
||||||
|
@ -651,7 +669,7 @@ static void DrawOneWeapon(player_t * CPlayer, int x, int & y, AWeapon * weapon)
|
||||||
if (weapon==CPlayer->ReadyWeapon || weapon==CPlayer->ReadyWeapon->SisterWeapon) trans=0xd999;
|
if (weapon==CPlayer->ReadyWeapon || weapon==CPlayer->ReadyWeapon->SisterWeapon) trans=0xd999;
|
||||||
}
|
}
|
||||||
|
|
||||||
FTextureID picnum = GetWeaponIcon(weapon);
|
FTextureID picnum = GetInventoryIcon(weapon, DI_ALTICONFIRST);
|
||||||
|
|
||||||
if (picnum.isValid())
|
if (picnum.isValid())
|
||||||
{
|
{
|
||||||
|
|
|
@ -42,8 +42,6 @@
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <lmcons.h>
|
|
||||||
#include <shlobj.h>
|
|
||||||
extern HWND Window;
|
extern HWND Window;
|
||||||
#define USE_WINDOWS_DWORD
|
#define USE_WINDOWS_DWORD
|
||||||
#endif
|
#endif
|
||||||
|
@ -588,106 +586,20 @@ void FGameConfigFile::ArchiveGlobalData ()
|
||||||
FString FGameConfigFile::GetConfigPath (bool tryProg)
|
FString FGameConfigFile::GetConfigPath (bool tryProg)
|
||||||
{
|
{
|
||||||
const char *pathval;
|
const char *pathval;
|
||||||
FString path;
|
|
||||||
|
|
||||||
pathval = Args->CheckValue ("-config");
|
pathval = Args->CheckValue ("-config");
|
||||||
if (pathval != NULL)
|
if (pathval != NULL)
|
||||||
{
|
{
|
||||||
return FString(pathval);
|
return FString(pathval);
|
||||||
}
|
}
|
||||||
#ifdef _WIN32
|
return M_GetConfigPath(tryProg);
|
||||||
path = NULL;
|
|
||||||
HRESULT hr;
|
|
||||||
|
|
||||||
TCHAR uname[UNLEN+1];
|
|
||||||
DWORD unamelen = countof(uname);
|
|
||||||
|
|
||||||
// Because people complained, try for a user-specific .ini in the program directory first.
|
|
||||||
// If that is not writeable, use the one in the home directory instead.
|
|
||||||
hr = GetUserName (uname, &unamelen);
|
|
||||||
if (SUCCEEDED(hr) && uname[0] != 0)
|
|
||||||
{
|
|
||||||
// Is it valid for a user name to have slashes?
|
|
||||||
// Check for them and substitute just in case.
|
|
||||||
char *probe = uname;
|
|
||||||
while (*probe != 0)
|
|
||||||
{
|
|
||||||
if (*probe == '\\' || *probe == '/')
|
|
||||||
*probe = '_';
|
|
||||||
++probe;
|
|
||||||
}
|
|
||||||
|
|
||||||
path = progdir;
|
|
||||||
path += "zdoom-";
|
|
||||||
path += uname;
|
|
||||||
path += ".ini";
|
|
||||||
if (tryProg)
|
|
||||||
{
|
|
||||||
if (!FileExists (path.GetChars()))
|
|
||||||
{
|
|
||||||
path = "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{ // check if writeable
|
|
||||||
FILE *checker = fopen (path.GetChars(), "a");
|
|
||||||
if (checker == NULL)
|
|
||||||
{
|
|
||||||
path = "";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
fclose (checker);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (path.IsEmpty())
|
|
||||||
{
|
|
||||||
if (Args->CheckParm ("-cdrom"))
|
|
||||||
return CDROM_DIR "\\zdoom.ini";
|
|
||||||
|
|
||||||
path = progdir;
|
|
||||||
path += "zdoom.ini";
|
|
||||||
}
|
|
||||||
return path;
|
|
||||||
#elif defined(__APPLE__)
|
|
||||||
char cpath[PATH_MAX];
|
|
||||||
FSRef folder;
|
|
||||||
|
|
||||||
if (noErr == FSFindFolder(kUserDomain, kPreferencesFolderType, kCreateFolder, &folder) &&
|
|
||||||
noErr == FSRefMakePath(&folder, (UInt8*)cpath, PATH_MAX))
|
|
||||||
{
|
|
||||||
path = cpath;
|
|
||||||
path += "/zdoom.ini";
|
|
||||||
return path;
|
|
||||||
}
|
|
||||||
// Ungh.
|
|
||||||
return "zdoom.ini";
|
|
||||||
#else
|
|
||||||
return GetUserFile ("zdoom.ini");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FGameConfigFile::CreateStandardAutoExec(const char *section, bool start)
|
void FGameConfigFile::CreateStandardAutoExec(const char *section, bool start)
|
||||||
{
|
{
|
||||||
if (!SetSection(section))
|
if (!SetSection(section))
|
||||||
{
|
{
|
||||||
FString path;
|
FString path = M_GetAutoexecPath();
|
||||||
#ifdef __APPLE__
|
|
||||||
char cpath[PATH_MAX];
|
|
||||||
FSRef folder;
|
|
||||||
|
|
||||||
if (noErr == FSFindFolder(kUserDomain, kDocumentsFolderType, kCreateFolder, &folder) &&
|
|
||||||
noErr == FSRefMakePath(&folder, (UInt8*)cpath, PATH_MAX))
|
|
||||||
{
|
|
||||||
path << cpath << "/" GAME_DIR "/autoexec.cfg";
|
|
||||||
}
|
|
||||||
#elif !defined(__unix__)
|
|
||||||
path = "$PROGDIR/autoexec.cfg";
|
|
||||||
#else
|
|
||||||
path = GetUserFile ("autoexec.cfg");
|
|
||||||
#endif
|
|
||||||
SetSection (section, true);
|
SetSection (section, true);
|
||||||
SetValueForKey ("Path", path.GetChars());
|
SetValueForKey ("Path", path.GetChars());
|
||||||
}
|
}
|
||||||
|
@ -794,6 +706,6 @@ void FGameConfigFile::SetRavenDefaults (bool isHexen)
|
||||||
|
|
||||||
CCMD (whereisini)
|
CCMD (whereisini)
|
||||||
{
|
{
|
||||||
FString path = GameConfig->GetConfigPath (false);
|
FString path = M_GetConfigPath(false);
|
||||||
Printf ("%s\n", path.GetChars());
|
Printf ("%s\n", path.GetChars());
|
||||||
}
|
}
|
||||||
|
|
111
src/m_misc.cpp
111
src/m_misc.cpp
|
@ -31,9 +31,6 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#ifdef __APPLE__
|
|
||||||
#include <CoreServices/CoreServices.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "doomtype.h"
|
#include "doomtype.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
@ -333,65 +330,6 @@ static long ParseCommandLine (const char *args, int *argc, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if defined(__unix__)
|
|
||||||
FString GetUserFile (const char *file)
|
|
||||||
{
|
|
||||||
FString path;
|
|
||||||
struct stat info;
|
|
||||||
|
|
||||||
path = NicePath("~/" GAME_DIR "/");
|
|
||||||
|
|
||||||
if (stat (path, &info) == -1)
|
|
||||||
{
|
|
||||||
struct stat extrainfo;
|
|
||||||
|
|
||||||
// Sanity check for ~/.config
|
|
||||||
FString configPath = NicePath("~/.config/");
|
|
||||||
if (stat (configPath, &extrainfo) == -1)
|
|
||||||
{
|
|
||||||
if (mkdir (configPath, S_IRUSR | S_IWUSR | S_IXUSR) == -1)
|
|
||||||
{
|
|
||||||
I_FatalError ("Failed to create ~/.config directory:\n%s", strerror(errno));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (!S_ISDIR(extrainfo.st_mode))
|
|
||||||
{
|
|
||||||
I_FatalError ("~/.config must be a directory");
|
|
||||||
}
|
|
||||||
|
|
||||||
// This can be removed after a release or two
|
|
||||||
// Transfer the old zdoom directory to the new location
|
|
||||||
bool moved = false;
|
|
||||||
FString oldpath = NicePath("~/.zdoom/");
|
|
||||||
if (stat (oldpath, &extrainfo) != -1)
|
|
||||||
{
|
|
||||||
if (rename(oldpath, path) == -1)
|
|
||||||
{
|
|
||||||
I_Error ("Failed to move old zdoom directory (%s) to new location (%s).",
|
|
||||||
oldpath.GetChars(), path.GetChars());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
moved = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!moved && mkdir (path, S_IRUSR | S_IWUSR | S_IXUSR) == -1)
|
|
||||||
{
|
|
||||||
I_FatalError ("Failed to create %s directory:\n%s",
|
|
||||||
path.GetChars(), strerror (errno));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!S_ISDIR(info.st_mode))
|
|
||||||
{
|
|
||||||
I_FatalError ("%s must be a directory", path.GetChars());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
path += file;
|
|
||||||
return path;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// M_SaveDefaults
|
// M_SaveDefaults
|
||||||
//
|
//
|
||||||
|
@ -698,48 +636,23 @@ void M_ScreenShot (const char *filename)
|
||||||
// find a file name to save it to
|
// find a file name to save it to
|
||||||
if (filename == NULL || filename[0] == '\0')
|
if (filename == NULL || filename[0] == '\0')
|
||||||
{
|
{
|
||||||
#if !defined(__unix__) && !defined(__APPLE__)
|
size_t dirlen;
|
||||||
if (Args->CheckParm ("-cdrom"))
|
autoname = Args->CheckValue("-shotdir");
|
||||||
|
if (autoname.IsEmpty())
|
||||||
{
|
{
|
||||||
autoname = CDROM_DIR "\\";
|
autoname = screenshot_dir;
|
||||||
}
|
}
|
||||||
else
|
dirlen = autoname.Len();
|
||||||
#endif
|
if (dirlen == 0)
|
||||||
{
|
{
|
||||||
size_t dirlen;
|
autoname = M_GetScreenshotsPath();
|
||||||
autoname = Args->CheckValue("-shotdir");
|
|
||||||
if (autoname.IsEmpty())
|
|
||||||
{
|
|
||||||
autoname = screenshot_dir;
|
|
||||||
}
|
|
||||||
dirlen = autoname.Len();
|
dirlen = autoname.Len();
|
||||||
if (dirlen == 0)
|
}
|
||||||
|
if (dirlen > 0)
|
||||||
|
{
|
||||||
|
if (autoname[dirlen-1] != '/' && autoname[dirlen-1] != '\\')
|
||||||
{
|
{
|
||||||
#ifdef __unix__
|
autoname += '/';
|
||||||
autoname = "~/" GAME_DIR "/screenshots/";
|
|
||||||
#elif defined(__APPLE__)
|
|
||||||
char cpath[PATH_MAX];
|
|
||||||
FSRef folder;
|
|
||||||
|
|
||||||
if (noErr == FSFindFolder(kUserDomain, kDocumentsFolderType, kCreateFolder, &folder) &&
|
|
||||||
noErr == FSRefMakePath(&folder, (UInt8*)cpath, PATH_MAX))
|
|
||||||
{
|
|
||||||
autoname << cpath << "/" GAME_DIR "/Screenshots/";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
autoname = "~";
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
autoname = progdir;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
else if (dirlen > 0)
|
|
||||||
{
|
|
||||||
if (autoname[dirlen-1] != '/' && autoname[dirlen-1] != '\\')
|
|
||||||
{
|
|
||||||
autoname += '/';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
autoname = NicePath(autoname);
|
autoname = NicePath(autoname);
|
||||||
|
|
15
src/m_misc.h
15
src/m_misc.h
|
@ -24,6 +24,7 @@
|
||||||
#define __M_MISC__
|
#define __M_MISC__
|
||||||
|
|
||||||
#include "basictypes.h"
|
#include "basictypes.h"
|
||||||
|
#include "zstring.h"
|
||||||
|
|
||||||
class FConfigFile;
|
class FConfigFile;
|
||||||
class FGameConfigFile;
|
class FGameConfigFile;
|
||||||
|
@ -44,9 +45,19 @@ bool M_SaveDefaults (const char *filename);
|
||||||
void M_SaveCustomKeys (FConfigFile *config, char *section, char *subsection, size_t sublen);
|
void M_SaveCustomKeys (FConfigFile *config, char *section, char *subsection, size_t sublen);
|
||||||
|
|
||||||
|
|
||||||
// Prepends ~/.zdoom to path
|
|
||||||
FString GetUserFile (const char *path);
|
|
||||||
|
|
||||||
FString M_ZLibError(int zerrnum);
|
FString M_ZLibError(int zerrnum);
|
||||||
|
|
||||||
|
// Get special directory paths (defined in m_specialpaths.cpp)
|
||||||
|
|
||||||
|
#ifdef __unix__
|
||||||
|
FString GetUserFile (const char *path); // Prepends ~/.zdoom to path
|
||||||
|
#endif
|
||||||
|
FString M_GetCachePath(bool create);
|
||||||
|
FString M_GetAutoexecPath();
|
||||||
|
FString M_GetCajunPath(const char *filename);
|
||||||
|
FString M_GetConfigPath(bool for_reading);
|
||||||
|
FString M_GetScreenshotsPath();
|
||||||
|
FString M_GetSavegamesPath();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
630
src/m_specialpaths.cpp
Normal file
630
src/m_specialpaths.cpp
Normal file
|
@ -0,0 +1,630 @@
|
||||||
|
#ifdef __APPLE__
|
||||||
|
#include <CoreServices/CoreServices.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include <windows.h>
|
||||||
|
#include <lmcons.h>
|
||||||
|
#include <shlobj.h>
|
||||||
|
#define USE_WINDOWS_DWORD
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "cmdlib.h"
|
||||||
|
#include "m_misc.h"
|
||||||
|
|
||||||
|
#if !defined(__APPLE__) && !defined(_WIN32)
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include "i_system.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "version.h" // for GAMENAME
|
||||||
|
|
||||||
|
#if defined(_WIN32)
|
||||||
|
|
||||||
|
typedef HRESULT (WINAPI *GKFP)(REFKNOWNFOLDERID, DWORD, HANDLE, PWSTR *);
|
||||||
|
|
||||||
|
//===========================================================================
|
||||||
|
//
|
||||||
|
// IsProgramDirectoryWritable
|
||||||
|
//
|
||||||
|
// If the program directory is writable, then dump everything in there for
|
||||||
|
// historical reasons. Otherwise, known folders get used instead.
|
||||||
|
//
|
||||||
|
//===========================================================================
|
||||||
|
|
||||||
|
bool UseKnownFolders()
|
||||||
|
{
|
||||||
|
// Cache this value so the semantics don't change during a single run
|
||||||
|
// of the program. (e.g. Somebody could add write access while the
|
||||||
|
// program is running.)
|
||||||
|
static INTBOOL iswritable = -1;
|
||||||
|
FString testpath;
|
||||||
|
HANDLE file;
|
||||||
|
|
||||||
|
if (iswritable >= 0)
|
||||||
|
{
|
||||||
|
return !iswritable;
|
||||||
|
}
|
||||||
|
testpath << progdir << "writest";
|
||||||
|
file = CreateFile(testpath, GENERIC_READ | GENERIC_WRITE, 0, NULL,
|
||||||
|
CREATE_ALWAYS,
|
||||||
|
FILE_ATTRIBUTE_TEMPORARY | FILE_FLAG_DELETE_ON_CLOSE, NULL);
|
||||||
|
if (file != INVALID_HANDLE_VALUE)
|
||||||
|
{
|
||||||
|
CloseHandle(file);
|
||||||
|
Printf("Using program directory for storage\n");
|
||||||
|
iswritable = true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Printf("Using known folders for storage\n");
|
||||||
|
iswritable = false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//===========================================================================
|
||||||
|
//
|
||||||
|
// GetKnownFolder
|
||||||
|
//
|
||||||
|
// Returns the known_folder if SHGetKnownFolderPath is available, otherwise
|
||||||
|
// returns the shell_folder using SHGetFolderPath.
|
||||||
|
//
|
||||||
|
//===========================================================================
|
||||||
|
|
||||||
|
bool GetKnownFolder(int shell_folder, REFKNOWNFOLDERID known_folder, bool create, FString &path)
|
||||||
|
{
|
||||||
|
static GKFP SHGetKnownFolderPath = NULL;
|
||||||
|
static bool tested = false;
|
||||||
|
|
||||||
|
if (!tested)
|
||||||
|
{
|
||||||
|
tested = true;
|
||||||
|
HMODULE shell32 = GetModuleHandle("shell32.dll");
|
||||||
|
if (shell32 != NULL)
|
||||||
|
{
|
||||||
|
SHGetKnownFolderPath = (GKFP)GetProcAddress(shell32, "SHGetKnownFolderPath");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
char pathstr[MAX_PATH];
|
||||||
|
|
||||||
|
// SHGetKnownFolderPath knows about more folders than SHGetFolderPath, but is
|
||||||
|
// new to Vista, hence the reason we support both.
|
||||||
|
if (SHGetKnownFolderPath == NULL)
|
||||||
|
{
|
||||||
|
if (shell_folder < 0)
|
||||||
|
{ // Not supported by SHGetFolderPath
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (create)
|
||||||
|
{
|
||||||
|
shell_folder |= CSIDL_FLAG_CREATE;
|
||||||
|
}
|
||||||
|
if (FAILED(SHGetFolderPathA(NULL, shell_folder, NULL, 0, pathstr)))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
path = pathstr;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PWSTR wpath;
|
||||||
|
if (FAILED(SHGetKnownFolderPath(known_folder, create ? KF_FLAG_CREATE : 0, NULL, &wpath)))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// FIXME: Support Unicode, at least for filenames. This function
|
||||||
|
// has no MBCS equivalent, so we have to convert it since we don't
|
||||||
|
// support Unicode. :(
|
||||||
|
bool converted = false;
|
||||||
|
if (WideCharToMultiByte(GetACP(), WC_NO_BEST_FIT_CHARS, wpath, -1,
|
||||||
|
pathstr, countof(pathstr), NULL, NULL) > 0)
|
||||||
|
{
|
||||||
|
path = pathstr;
|
||||||
|
converted = true;
|
||||||
|
}
|
||||||
|
CoTaskMemFree(wpath);
|
||||||
|
return converted;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//===========================================================================
|
||||||
|
//
|
||||||
|
// M_GetCachePath Windows
|
||||||
|
//
|
||||||
|
// Returns the path for cache GL nodes.
|
||||||
|
//
|
||||||
|
//===========================================================================
|
||||||
|
|
||||||
|
FString M_GetCachePath(bool create)
|
||||||
|
{
|
||||||
|
FString path;
|
||||||
|
|
||||||
|
if (!GetKnownFolder(CSIDL_LOCAL_APPDATA, FOLDERID_LocalAppData, create, path))
|
||||||
|
{ // Failed (e.g. On Win9x): use program directory
|
||||||
|
path = progdir;
|
||||||
|
}
|
||||||
|
// Don't use GAME_DIR and such so that ZDoom and its child ports can
|
||||||
|
// share the node cache.
|
||||||
|
path += "/zdoom/cache";
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
//===========================================================================
|
||||||
|
//
|
||||||
|
// M_GetAutoexecPath Windows
|
||||||
|
//
|
||||||
|
// Returns the expected location of autoexec.cfg.
|
||||||
|
//
|
||||||
|
//===========================================================================
|
||||||
|
|
||||||
|
FString M_GetAutoexecPath()
|
||||||
|
{
|
||||||
|
return "$PROGDIR/autoexec.cfg";
|
||||||
|
}
|
||||||
|
|
||||||
|
//===========================================================================
|
||||||
|
//
|
||||||
|
// M_GetCajunPath Windows
|
||||||
|
//
|
||||||
|
// Returns the location of the Cajun Bot definitions.
|
||||||
|
//
|
||||||
|
//===========================================================================
|
||||||
|
|
||||||
|
FString M_GetCajunPath(const char *botfilename)
|
||||||
|
{
|
||||||
|
FString path;
|
||||||
|
|
||||||
|
path << progdir << "zcajun/" << botfilename;
|
||||||
|
if (!FileExists(path))
|
||||||
|
{
|
||||||
|
path = "";
|
||||||
|
}
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
//===========================================================================
|
||||||
|
//
|
||||||
|
// M_GetConfigPath Windows
|
||||||
|
//
|
||||||
|
// Returns the path to the config file. On Windows, this can vary for reading
|
||||||
|
// vs writing. i.e. If $PROGDIR/zdoom-<user>.ini does not exist, it will try
|
||||||
|
// to read from $PROGDIR/zdoom.ini, but it will never write to zdoom.ini.
|
||||||
|
//
|
||||||
|
//===========================================================================
|
||||||
|
|
||||||
|
FString M_GetConfigPath(bool for_reading)
|
||||||
|
{
|
||||||
|
FString path;
|
||||||
|
HRESULT hr;
|
||||||
|
|
||||||
|
// Construct a user-specific config name
|
||||||
|
if (UseKnownFolders() && GetKnownFolder(CSIDL_APPDATA, FOLDERID_RoamingAppData, true, path))
|
||||||
|
{
|
||||||
|
path += "/" GAME_DIR;
|
||||||
|
CreatePath(path);
|
||||||
|
path += "/zdoom.ini";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ // construct "$PROGDIR/zdoom-$USER.ini"
|
||||||
|
TCHAR uname[UNLEN+1];
|
||||||
|
DWORD unamelen = countof(uname);
|
||||||
|
|
||||||
|
path = progdir;
|
||||||
|
hr = GetUserName(uname, &unamelen);
|
||||||
|
if (SUCCEEDED(hr) && uname[0] != 0)
|
||||||
|
{
|
||||||
|
// Is it valid for a user name to have slashes?
|
||||||
|
// Check for them and substitute just in case.
|
||||||
|
char *probe = uname;
|
||||||
|
while (*probe != 0)
|
||||||
|
{
|
||||||
|
if (*probe == '\\' || *probe == '/')
|
||||||
|
*probe = '_';
|
||||||
|
++probe;
|
||||||
|
}
|
||||||
|
path << "zdoom-" << uname << ".ini";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ // Couldn't get user name, so just use zdoom.ini
|
||||||
|
path += "zdoom.ini";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we are reading the config file, check if it exists. If not, fallback
|
||||||
|
// to $PROGDIR/zdoom.ini
|
||||||
|
if (for_reading)
|
||||||
|
{
|
||||||
|
if (!FileExists(path))
|
||||||
|
{
|
||||||
|
path = progdir;
|
||||||
|
path << "zdoom.ini";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
//===========================================================================
|
||||||
|
//
|
||||||
|
// M_GetScreenshotsPath Windows
|
||||||
|
//
|
||||||
|
// Returns the path to the default screenshots directory.
|
||||||
|
//
|
||||||
|
//===========================================================================
|
||||||
|
|
||||||
|
// I'm not sure when FOLDERID_Screenshots was added, but it was probably
|
||||||
|
// for Windows 8, since it's not in the v7.0 Windows SDK.
|
||||||
|
static const GUID MyFOLDERID_Screenshots = { 0xb7bede81, 0xdf94, 0x4682, 0xa7, 0xd8, 0x57, 0xa5, 0x26, 0x20, 0xb8, 0x6f };
|
||||||
|
|
||||||
|
FString M_GetScreenshotsPath()
|
||||||
|
{
|
||||||
|
FString path;
|
||||||
|
|
||||||
|
if (!UseKnownFolders())
|
||||||
|
{
|
||||||
|
return progdir;
|
||||||
|
}
|
||||||
|
else if (GetKnownFolder(-1, MyFOLDERID_Screenshots, true, path))
|
||||||
|
{
|
||||||
|
path << "/" GAMENAME;
|
||||||
|
}
|
||||||
|
else if (GetKnownFolder(CSIDL_MYPICTURES, FOLDERID_Pictures, true, path))
|
||||||
|
{
|
||||||
|
path << "/Screenshots/" GAMENAME;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return progdir;
|
||||||
|
}
|
||||||
|
CreatePath(path);
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
//===========================================================================
|
||||||
|
//
|
||||||
|
// M_GetSavegamesPath Windows
|
||||||
|
//
|
||||||
|
// Returns the path to the default save games directory.
|
||||||
|
//
|
||||||
|
//===========================================================================
|
||||||
|
|
||||||
|
FString M_GetSavegamesPath()
|
||||||
|
{
|
||||||
|
FString path;
|
||||||
|
|
||||||
|
if (!UseKnownFolders())
|
||||||
|
{
|
||||||
|
return progdir;
|
||||||
|
}
|
||||||
|
// Try standard Saved Games folder
|
||||||
|
else if (GetKnownFolder(-1, FOLDERID_SavedGames, true, path))
|
||||||
|
{
|
||||||
|
path << "/" GAMENAME;
|
||||||
|
}
|
||||||
|
// Try defacto My Documents/My Games folder
|
||||||
|
else if (GetKnownFolder(CSIDL_PERSONAL, FOLDERID_Documents, true, path))
|
||||||
|
{
|
||||||
|
// I assume since this isn't a standard folder, it doesn't have
|
||||||
|
// a localized name either.
|
||||||
|
path << "/My Games/" GAMENAME;
|
||||||
|
CreatePath(path);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
path = progdir;
|
||||||
|
}
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
#elif defined(__APPLE__)
|
||||||
|
|
||||||
|
//===========================================================================
|
||||||
|
//
|
||||||
|
// M_GetCachePath Mac OS X
|
||||||
|
//
|
||||||
|
// Returns the path for cache GL nodes.
|
||||||
|
//
|
||||||
|
//===========================================================================
|
||||||
|
|
||||||
|
FString M_GetCachePath(bool create)
|
||||||
|
{
|
||||||
|
FString path;
|
||||||
|
|
||||||
|
char pathstr[PATH_MAX];
|
||||||
|
FSRef folder;
|
||||||
|
|
||||||
|
if (noErr == FSFindFolder(kLocalDomain, kApplicationSupportFolderType, create ? kCreateFolder : 0, &folder) &&
|
||||||
|
noErr == FSRefMakePath(&folder, (UInt8*)pathstr, PATH_MAX))
|
||||||
|
{
|
||||||
|
path = pathstr;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
path = progdir;
|
||||||
|
}
|
||||||
|
path += "/zdoom/cache";
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
//===========================================================================
|
||||||
|
//
|
||||||
|
// M_GetAutoexecPath Mac OS X
|
||||||
|
//
|
||||||
|
// Returns the expected location of autoexec.cfg.
|
||||||
|
//
|
||||||
|
//===========================================================================
|
||||||
|
|
||||||
|
FString M_GetAutoexecPath()
|
||||||
|
{
|
||||||
|
FString path;
|
||||||
|
|
||||||
|
char cpath[PATH_MAX];
|
||||||
|
FSRef folder;
|
||||||
|
|
||||||
|
if (noErr == FSFindFolder(kUserDomain, kDocumentsFolderType, kCreateFolder, &folder) &&
|
||||||
|
noErr == FSRefMakePath(&folder, (UInt8*)cpath, PATH_MAX))
|
||||||
|
{
|
||||||
|
path << cpath << "/" GAME_DIR "/autoexec.cfg";
|
||||||
|
}
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
//===========================================================================
|
||||||
|
//
|
||||||
|
// M_GetCajunPath Mac OS X
|
||||||
|
//
|
||||||
|
// Returns the location of the Cajun Bot definitions.
|
||||||
|
//
|
||||||
|
//===========================================================================
|
||||||
|
|
||||||
|
FString M_GetCajunPath(const char *botfilename)
|
||||||
|
{
|
||||||
|
FString path;
|
||||||
|
|
||||||
|
// Just copies the Windows code. Should this be more Mac-specific?
|
||||||
|
path << progdir << "zcajun/" << botfilename;
|
||||||
|
if (!FileExists(path))
|
||||||
|
{
|
||||||
|
path = "";
|
||||||
|
}
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
//===========================================================================
|
||||||
|
//
|
||||||
|
// M_GetConfigPath Mac OS X
|
||||||
|
//
|
||||||
|
// Returns the path to the config file. On Windows, this can vary for reading
|
||||||
|
// vs writing. i.e. If $PROGDIR/zdoom-<user>.ini does not exist, it will try
|
||||||
|
// to read from $PROGDIR/zdoom.ini, but it will never write to zdoom.ini.
|
||||||
|
//
|
||||||
|
//===========================================================================
|
||||||
|
|
||||||
|
FString M_GetConfigPath(bool for_reading)
|
||||||
|
{
|
||||||
|
char cpath[PATH_MAX];
|
||||||
|
FSRef folder;
|
||||||
|
|
||||||
|
if (noErr == FSFindFolder(kUserDomain, kPreferencesFolderType, kCreateFolder, &folder) &&
|
||||||
|
noErr == FSRefMakePath(&folder, (UInt8*)cpath, PATH_MAX))
|
||||||
|
{
|
||||||
|
FString path;
|
||||||
|
path << cpath << "/zdoom.ini";
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
// Ungh.
|
||||||
|
return "zdoom.ini";
|
||||||
|
}
|
||||||
|
|
||||||
|
//===========================================================================
|
||||||
|
//
|
||||||
|
// M_GetScreenshotsPath Mac OS X
|
||||||
|
//
|
||||||
|
// Returns the path to the default screenshots directory.
|
||||||
|
//
|
||||||
|
//===========================================================================
|
||||||
|
|
||||||
|
FString M_GetScreenshotsPath()
|
||||||
|
{
|
||||||
|
FString path;
|
||||||
|
char cpath[PATH_MAX];
|
||||||
|
FSRef folder;
|
||||||
|
|
||||||
|
if (noErr == FSFindFolder(kUserDomain, kDocumentsFolderType, kCreateFolder, &folder) &&
|
||||||
|
noErr == FSRefMakePath(&folder, (UInt8*)cpath, PATH_MAX))
|
||||||
|
{
|
||||||
|
path << cpath << "/" GAME_DIR "/Screenshots/";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
path = "~/";
|
||||||
|
}
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
//===========================================================================
|
||||||
|
//
|
||||||
|
// M_GetSavegamesPath Mac OS X
|
||||||
|
//
|
||||||
|
// Returns the path to the default save games directory.
|
||||||
|
//
|
||||||
|
//===========================================================================
|
||||||
|
|
||||||
|
FString M_GetSavegamesPath()
|
||||||
|
{
|
||||||
|
FString path;
|
||||||
|
char cpath[PATH_MAX];
|
||||||
|
FSRef folder;
|
||||||
|
|
||||||
|
if (noErr == FSFindFolder(kUserDomain, kDocumentsFolderType, kCreateFolder, &folder) &&
|
||||||
|
noErr == FSRefMakePath(&folder, (UInt8*)cpath, PATH_MAX))
|
||||||
|
{
|
||||||
|
path << cpath << "/" GAME_DIR "/Savegames/";
|
||||||
|
}
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else // Linux, et al.
|
||||||
|
|
||||||
|
|
||||||
|
FString GetUserFile (const char *file)
|
||||||
|
{
|
||||||
|
FString path;
|
||||||
|
struct stat info;
|
||||||
|
|
||||||
|
path = NicePath("~/" GAME_DIR "/");
|
||||||
|
|
||||||
|
if (stat (path, &info) == -1)
|
||||||
|
{
|
||||||
|
struct stat extrainfo;
|
||||||
|
|
||||||
|
// Sanity check for ~/.config
|
||||||
|
FString configPath = NicePath("~/.config/");
|
||||||
|
if (stat (configPath, &extrainfo) == -1)
|
||||||
|
{
|
||||||
|
if (mkdir (configPath, S_IRUSR | S_IWUSR | S_IXUSR) == -1)
|
||||||
|
{
|
||||||
|
I_FatalError ("Failed to create ~/.config directory:\n%s", strerror(errno));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (!S_ISDIR(extrainfo.st_mode))
|
||||||
|
{
|
||||||
|
I_FatalError ("~/.config must be a directory");
|
||||||
|
}
|
||||||
|
|
||||||
|
// This can be removed after a release or two
|
||||||
|
// Transfer the old zdoom directory to the new location
|
||||||
|
bool moved = false;
|
||||||
|
FString oldpath = NicePath("~/.zdoom/");
|
||||||
|
if (stat (oldpath, &extrainfo) != -1)
|
||||||
|
{
|
||||||
|
if (rename(oldpath, path) == -1)
|
||||||
|
{
|
||||||
|
I_Error ("Failed to move old zdoom directory (%s) to new location (%s).",
|
||||||
|
oldpath.GetChars(), path.GetChars());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
moved = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!moved && mkdir (path, S_IRUSR | S_IWUSR | S_IXUSR) == -1)
|
||||||
|
{
|
||||||
|
I_FatalError ("Failed to create %s directory:\n%s",
|
||||||
|
path.GetChars(), strerror (errno));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!S_ISDIR(info.st_mode))
|
||||||
|
{
|
||||||
|
I_FatalError ("%s must be a directory", path.GetChars());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
path += file;
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
//===========================================================================
|
||||||
|
//
|
||||||
|
// M_GetCachePath Unix
|
||||||
|
//
|
||||||
|
// Returns the path for cache GL nodes.
|
||||||
|
//
|
||||||
|
//===========================================================================
|
||||||
|
|
||||||
|
FString M_GetCachePath(bool create)
|
||||||
|
{
|
||||||
|
// Don't use GAME_DIR and such so that ZDoom and its child ports can
|
||||||
|
// share the node cache.
|
||||||
|
FString path = NicePath("~/.config/zdoom/cache");
|
||||||
|
if (create)
|
||||||
|
{
|
||||||
|
CreatePath(path);
|
||||||
|
}
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
//===========================================================================
|
||||||
|
//
|
||||||
|
// M_GetAutoexecPath Unix
|
||||||
|
//
|
||||||
|
// Returns the expected location of autoexec.cfg.
|
||||||
|
//
|
||||||
|
//===========================================================================
|
||||||
|
|
||||||
|
FString M_GetAutoexecPath()
|
||||||
|
{
|
||||||
|
return GetUserFile("autoexec.cfg");
|
||||||
|
}
|
||||||
|
|
||||||
|
//===========================================================================
|
||||||
|
//
|
||||||
|
// M_GetCajunPath Unix
|
||||||
|
//
|
||||||
|
// Returns the location of the Cajun Bot definitions.
|
||||||
|
//
|
||||||
|
//===========================================================================
|
||||||
|
|
||||||
|
FString M_GetCajunPath(const char *botfilename)
|
||||||
|
{
|
||||||
|
FString path;
|
||||||
|
|
||||||
|
// Check first in ~/.config/zdoom/botfilename.
|
||||||
|
path = GetUserFile(botfilename);
|
||||||
|
if (!FileExists(path))
|
||||||
|
{
|
||||||
|
// Then check in SHARE_DIR/botfilename.
|
||||||
|
path = SHARE_DIR;
|
||||||
|
path << botfilename;
|
||||||
|
if (!FileExists(path))
|
||||||
|
{
|
||||||
|
path = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
//===========================================================================
|
||||||
|
//
|
||||||
|
// M_GetConfigPath Unix
|
||||||
|
//
|
||||||
|
// Returns the path to the config file. On Windows, this can vary for reading
|
||||||
|
// vs writing. i.e. If $PROGDIR/zdoom-<user>.ini does not exist, it will try
|
||||||
|
// to read from $PROGDIR/zdoom.ini, but it will never write to zdoom.ini.
|
||||||
|
//
|
||||||
|
//===========================================================================
|
||||||
|
|
||||||
|
FString M_GetConfigPath(bool for_reading)
|
||||||
|
{
|
||||||
|
return GetUserFile("zdoom.ini");
|
||||||
|
}
|
||||||
|
|
||||||
|
//===========================================================================
|
||||||
|
//
|
||||||
|
// M_GetScreenshotsPath Unix
|
||||||
|
//
|
||||||
|
// Returns the path to the default screenshots directory.
|
||||||
|
//
|
||||||
|
//===========================================================================
|
||||||
|
|
||||||
|
FString M_GetScreenshotsPath()
|
||||||
|
{
|
||||||
|
return NicePath("~/" GAME_DIR "/screenshots/");
|
||||||
|
}
|
||||||
|
|
||||||
|
//===========================================================================
|
||||||
|
//
|
||||||
|
// M_GetSavegamesPath Unix
|
||||||
|
//
|
||||||
|
// Returns the path to the default save games directory.
|
||||||
|
//
|
||||||
|
//===========================================================================
|
||||||
|
|
||||||
|
FString M_GetSavegamesPath()
|
||||||
|
{
|
||||||
|
return NicePath("~/" GAME_DIR);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -166,15 +166,18 @@ public:
|
||||||
NewWidth = SCREENWIDTH;
|
NewWidth = SCREENWIDTH;
|
||||||
NewHeight = SCREENHEIGHT;
|
NewHeight = SCREENHEIGHT;
|
||||||
}
|
}
|
||||||
OldWidth = SCREENWIDTH;
|
else
|
||||||
OldHeight = SCREENHEIGHT;
|
{
|
||||||
OldBits = DisplayBits;
|
OldWidth = SCREENWIDTH;
|
||||||
NewBits = BitTranslate[DummyDepthCvar];
|
OldHeight = SCREENHEIGHT;
|
||||||
setmodeneeded = true;
|
OldBits = DisplayBits;
|
||||||
testingmode = I_GetTime(false) + 5 * TICRATE;
|
NewBits = BitTranslate[DummyDepthCvar];
|
||||||
S_Sound (CHAN_VOICE | CHAN_UI, "menu/choose", snd_menuvolume, ATTN_NONE);
|
setmodeneeded = true;
|
||||||
SetModesMenu (NewWidth, NewHeight, NewBits);
|
testingmode = I_GetTime(false) + 5 * TICRATE;
|
||||||
return true;
|
S_Sound (CHAN_VOICE | CHAN_UI, "menu/choose", snd_menuvolume, ATTN_NONE);
|
||||||
|
SetModesMenu (NewWidth, NewHeight, NewBits);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return Super::Responder(ev);
|
return Super::Responder(ev);
|
||||||
}
|
}
|
||||||
|
@ -348,7 +351,7 @@ void M_InitVideoModesMenu ()
|
||||||
static bool GetSelectedSize (int *width, int *height)
|
static bool GetSelectedSize (int *width, int *height)
|
||||||
{
|
{
|
||||||
FOptionMenuDescriptor *opt = GetVideoModeMenu();
|
FOptionMenuDescriptor *opt = GetVideoModeMenu();
|
||||||
if (opt != NULL)
|
if (opt != NULL && (unsigned)opt->mSelectedItem < opt->mItems.Size())
|
||||||
{
|
{
|
||||||
int line = opt->mSelectedItem;
|
int line = opt->mSelectedItem;
|
||||||
int hsel;
|
int hsel;
|
||||||
|
|
|
@ -568,3 +568,4 @@ xx(NeverSwitchOnPickup)
|
||||||
xx(MoveBob)
|
xx(MoveBob)
|
||||||
xx(StillBob)
|
xx(StillBob)
|
||||||
xx(PlayerClass)
|
xx(PlayerClass)
|
||||||
|
xx(Wi_NoAutostartMap)
|
|
@ -915,7 +915,7 @@ void P_NewChaseDir(AActor * actor)
|
||||||
// MBF's monster_backing option. Made an actor flag instead. Also cleaned the code up to make it readable.
|
// MBF's monster_backing option. Made an actor flag instead. Also cleaned the code up to make it readable.
|
||||||
// Todo: implement the movement logic
|
// Todo: implement the movement logic
|
||||||
AActor *target = actor->target;
|
AActor *target = actor->target;
|
||||||
if (target->health > 0 && !actor->IsFriend(target))
|
if (target->health > 0 && !actor->IsFriend(target) && target != actor->goal)
|
||||||
{ // Live enemy target
|
{ // Live enemy target
|
||||||
|
|
||||||
if (actor->flags3 & MF3_AVOIDMELEE)
|
if (actor->flags3 & MF3_AVOIDMELEE)
|
||||||
|
|
|
@ -43,17 +43,6 @@
|
||||||
|
|
||||||
#define rmdir _rmdir
|
#define rmdir _rmdir
|
||||||
|
|
||||||
// TODO, maybe: stop using DWORD so I don't need to worry about conflicting
|
|
||||||
// with Windows' typedef. Then I could just include the header file instead
|
|
||||||
// of declaring everything here.
|
|
||||||
#define MAX_PATH 260
|
|
||||||
#define CSIDL_LOCAL_APPDATA 0x001c
|
|
||||||
extern "C" __declspec(dllimport) long __stdcall SHGetFolderPathA(void *hwnd, int csidl, void *hToken, unsigned long dwFlags, char *pszPath);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __APPLE__
|
|
||||||
#include <CoreServices/CoreServices.h>
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "templates.h"
|
#include "templates.h"
|
||||||
|
@ -75,6 +64,7 @@ extern "C" __declspec(dllimport) long __stdcall SHGetFolderPathA(void *hwnd, int
|
||||||
#include "x86.h"
|
#include "x86.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
#include "md5.h"
|
#include "md5.h"
|
||||||
|
#include "m_misc.h"
|
||||||
|
|
||||||
void P_GetPolySpots (MapData * lump, TArray<FNodeBuilder::FPolyStart> &spots, TArray<FNodeBuilder::FPolyStart> &anchors);
|
void P_GetPolySpots (MapData * lump, TArray<FNodeBuilder::FPolyStart> &spots, TArray<FNodeBuilder::FPolyStart> &anchors);
|
||||||
|
|
||||||
|
@ -1048,45 +1038,10 @@ bool P_CheckNodes(MapData * map, bool rebuilt, int buildtime)
|
||||||
|
|
||||||
typedef TArray<BYTE> MemFile;
|
typedef TArray<BYTE> MemFile;
|
||||||
|
|
||||||
static FString GetCachePath()
|
|
||||||
{
|
|
||||||
FString path;
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
char pathstr[MAX_PATH];
|
|
||||||
if (0 != SHGetFolderPathA(NULL, CSIDL_LOCAL_APPDATA, NULL, 0, pathstr))
|
|
||||||
{ // Failed (e.g. On Win9x): use program directory
|
|
||||||
path = progdir;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
path = pathstr;
|
|
||||||
}
|
|
||||||
path += "/zdoom/cache";
|
|
||||||
#elif defined(__APPLE__)
|
|
||||||
char pathstr[PATH_MAX];
|
|
||||||
FSRef folder;
|
|
||||||
|
|
||||||
if (noErr == FSFindFolder(kLocalDomain, kApplicationSupportFolderType, kCreateFolder, &folder) &&
|
|
||||||
noErr == FSRefMakePath(&folder, (UInt8*)pathstr, PATH_MAX))
|
|
||||||
{
|
|
||||||
path = pathstr;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
path = progdir;
|
|
||||||
}
|
|
||||||
path += "/zdoom/cache";
|
|
||||||
#else
|
|
||||||
// Don't use GAME_DIR and such so that ZDoom and its child ports can share the node cache.
|
|
||||||
path = NicePath("~/.config/zdoom/cache");
|
|
||||||
#endif
|
|
||||||
return path;
|
|
||||||
}
|
|
||||||
|
|
||||||
static FString CreateCacheName(MapData *map, bool create)
|
static FString CreateCacheName(MapData *map, bool create)
|
||||||
{
|
{
|
||||||
FString path = GetCachePath();
|
FString path = M_GetCachePath(create);
|
||||||
FString lumpname = Wads.GetLumpFullPath(map->lumpnum);
|
FString lumpname = Wads.GetLumpFullPath(map->lumpnum);
|
||||||
int separator = lumpname.IndexOf(':');
|
int separator = lumpname.IndexOf(':');
|
||||||
path << '/' << lumpname.Left(separator);
|
path << '/' << lumpname.Left(separator);
|
||||||
|
@ -1299,7 +1254,7 @@ errorout:
|
||||||
CCMD(clearnodecache)
|
CCMD(clearnodecache)
|
||||||
{
|
{
|
||||||
TArray<FFileList> list;
|
TArray<FFileList> list;
|
||||||
FString path = GetCachePath();
|
FString path = M_GetCachePath(false);
|
||||||
path += "/";
|
path += "/";
|
||||||
|
|
||||||
try
|
try
|
||||||
|
|
|
@ -1562,9 +1562,21 @@ FUNC(LS_Thing_SetGoal)
|
||||||
ok = true;
|
ok = true;
|
||||||
if (self->flags & MF_SHOOTABLE)
|
if (self->flags & MF_SHOOTABLE)
|
||||||
{
|
{
|
||||||
|
if (self->target == self->goal)
|
||||||
|
{ // Targeting a goal already? -> don't target it anymore.
|
||||||
|
// A_Look will set it to the goal, presuming no real targets
|
||||||
|
// come into view by then.
|
||||||
|
self->target = NULL;
|
||||||
|
}
|
||||||
self->goal = goal;
|
self->goal = goal;
|
||||||
if (arg3 == 0) self->flags5 &=~ MF5_CHASEGOAL;
|
if (arg3 == 0)
|
||||||
else self->flags5 |= MF5_CHASEGOAL;
|
{
|
||||||
|
self->flags5 &= ~MF5_CHASEGOAL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
self->flags5 |= MF5_CHASEGOAL;
|
||||||
|
}
|
||||||
if (self->target == NULL)
|
if (self->target == NULL)
|
||||||
{
|
{
|
||||||
self->reactiontime = arg2 * TICRATE;
|
self->reactiontime = arg2 * TICRATE;
|
||||||
|
|
|
@ -3525,19 +3525,23 @@ void AActor::Tick ()
|
||||||
Destroy();
|
Destroy();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (ObjectFlags & OF_JustSpawned && state->GetNoDelay())
|
if ((flags7 & MF7_HANDLENODELAY) && !(flags2 & MF2_DORMANT))
|
||||||
{
|
{
|
||||||
// For immediately spawned objects with the NoDelay flag set for their
|
flags7 &= ~MF7_HANDLENODELAY;
|
||||||
// Spawn state, explicitly set the current state so that it calls its
|
if (state->GetNoDelay())
|
||||||
// action and chains 0-tic states.
|
|
||||||
int starttics = tics;
|
|
||||||
if (!SetState(state))
|
|
||||||
return; // freed itself
|
|
||||||
// If the initial state had a duration of 0 tics, let the next state run
|
|
||||||
// normally. Otherwise, increment tics by 1 so that we don't double up ticks.
|
|
||||||
if (starttics > 0 && tics >= 0)
|
|
||||||
{
|
{
|
||||||
tics++;
|
// For immediately spawned objects with the NoDelay flag set for their
|
||||||
|
// Spawn state, explicitly set the current state so that it calls its
|
||||||
|
// action and chains 0-tic states.
|
||||||
|
int starttics = tics;
|
||||||
|
if (!SetState(state))
|
||||||
|
return; // freed itself
|
||||||
|
// If the initial state had a duration of 0 tics, let the next state run
|
||||||
|
// normally. Otherwise, increment tics by 1 so that we don't double up ticks.
|
||||||
|
else if (starttics > 0 && tics >= 0)
|
||||||
|
{
|
||||||
|
tics++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// cycle through states, calling action functions at transitions
|
// cycle through states, calling action functions at transitions
|
||||||
|
@ -4024,6 +4028,7 @@ void AActor::PostBeginPlay ()
|
||||||
Renderer->StateChanged(this);
|
Renderer->StateChanged(this);
|
||||||
}
|
}
|
||||||
PrevAngle = angle;
|
PrevAngle = angle;
|
||||||
|
flags7 |= MF7_HANDLENODELAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AActor::MarkPrecacheSounds() const
|
void AActor::MarkPrecacheSounds() const
|
||||||
|
|
109
src/p_user.cpp
109
src/p_user.cpp
|
@ -314,6 +314,115 @@ player_t::player_t()
|
||||||
memset (&skill, 0, sizeof(skill));
|
memset (&skill, 0, sizeof(skill));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
player_t &player_t::operator=(const player_t &p)
|
||||||
|
{
|
||||||
|
mo = p.mo;
|
||||||
|
playerstate = p.playerstate;
|
||||||
|
cmd = p.cmd;
|
||||||
|
original_cmd = p.original_cmd;
|
||||||
|
original_oldbuttons = p.original_oldbuttons;
|
||||||
|
// Intentionally not copying userinfo!
|
||||||
|
cls = p.cls;
|
||||||
|
DesiredFOV = p.DesiredFOV;
|
||||||
|
FOV = p.FOV;
|
||||||
|
viewz = p.viewz;
|
||||||
|
viewheight = p.viewheight;
|
||||||
|
deltaviewheight = p.deltaviewheight;
|
||||||
|
bob = p.bob;
|
||||||
|
velx = p.velx;
|
||||||
|
vely = p.vely;
|
||||||
|
centering = p.centering;
|
||||||
|
turnticks = p.turnticks;
|
||||||
|
attackdown = p.attackdown;
|
||||||
|
usedown = p.usedown;
|
||||||
|
oldbuttons = p.oldbuttons;
|
||||||
|
health = p.health;
|
||||||
|
inventorytics = p.inventorytics;
|
||||||
|
CurrentPlayerClass = p.CurrentPlayerClass;
|
||||||
|
backpack = p.backpack;
|
||||||
|
memcpy(frags, &p.frags, sizeof(frags));
|
||||||
|
fragcount = p.fragcount;
|
||||||
|
lastkilltime = p.lastkilltime;
|
||||||
|
multicount = p.multicount;
|
||||||
|
spreecount = p.spreecount;
|
||||||
|
WeaponState = p.WeaponState;
|
||||||
|
ReadyWeapon = p.ReadyWeapon;
|
||||||
|
PendingWeapon = p.PendingWeapon;
|
||||||
|
cheats = p.cheats;
|
||||||
|
timefreezer = p.timefreezer;
|
||||||
|
refire = p.refire;
|
||||||
|
inconsistant = p.inconsistant;
|
||||||
|
waiting = p.waiting;
|
||||||
|
killcount = p.killcount;
|
||||||
|
itemcount = p.itemcount;
|
||||||
|
secretcount = p.secretcount;
|
||||||
|
damagecount = p.damagecount;
|
||||||
|
bonuscount = p.bonuscount;
|
||||||
|
hazardcount = p.hazardcount;
|
||||||
|
poisoncount = p.poisoncount;
|
||||||
|
poisontype = p.poisontype;
|
||||||
|
poisonpaintype = p.poisonpaintype;
|
||||||
|
poisoner = p.poisoner;
|
||||||
|
attacker = p.attacker;
|
||||||
|
extralight = p.extralight;
|
||||||
|
fixedcolormap = p.fixedcolormap;
|
||||||
|
fixedlightlevel = p.fixedlightlevel;
|
||||||
|
memcpy(psprites, &p.psprites, sizeof(psprites));
|
||||||
|
morphTics = p.morphTics;
|
||||||
|
MorphedPlayerClass = p.MorphedPlayerClass;
|
||||||
|
MorphStyle = p.MorphStyle;
|
||||||
|
MorphExitFlash = p.MorphExitFlash;
|
||||||
|
PremorphWeapon = p.PremorphWeapon;
|
||||||
|
chickenPeck = p.chickenPeck;
|
||||||
|
jumpTics = p.jumpTics;
|
||||||
|
respawn_time = p.respawn_time;
|
||||||
|
camera = p.camera;
|
||||||
|
air_finished = p.air_finished;
|
||||||
|
LastDamageType = p.LastDamageType;
|
||||||
|
savedyaw = p.savedyaw;
|
||||||
|
savedpitch = p.savedpitch;
|
||||||
|
angle = p.angle;
|
||||||
|
dest = p.dest;
|
||||||
|
prev = p.prev;
|
||||||
|
enemy = p.enemy;
|
||||||
|
missile = p.missile;
|
||||||
|
mate = p.mate;
|
||||||
|
last_mate = p.last_mate;
|
||||||
|
settings_controller = p.settings_controller;
|
||||||
|
skill = p.skill;
|
||||||
|
t_active = p.t_active;
|
||||||
|
t_respawn = p.t_respawn;
|
||||||
|
t_strafe = p.t_strafe;
|
||||||
|
t_react = p.t_react;
|
||||||
|
t_fight = p.t_fight;
|
||||||
|
t_roam = p.t_roam;
|
||||||
|
t_rocket = p.t_rocket;
|
||||||
|
isbot = p.isbot;
|
||||||
|
first_shot = p.first_shot;
|
||||||
|
sleft = p.sleft;
|
||||||
|
allround = p.allround;
|
||||||
|
oldx = p.oldx;
|
||||||
|
oldy = p.oldy;
|
||||||
|
BlendR = p.BlendR;
|
||||||
|
BlendG = p.BlendG;
|
||||||
|
BlendB = p.BlendB;
|
||||||
|
BlendA = p.BlendA;
|
||||||
|
LogText = p.LogText;
|
||||||
|
MinPitch = p.MinPitch;
|
||||||
|
MaxPitch = p.MaxPitch;
|
||||||
|
crouching = p.crouching;
|
||||||
|
crouchdir = p.crouchdir;
|
||||||
|
crouchfactor = p.crouchfactor;
|
||||||
|
crouchoffset = p.crouchoffset;
|
||||||
|
crouchviewdelta = p.crouchviewdelta;
|
||||||
|
weapons = p.weapons;
|
||||||
|
ConversationNPC = p.ConversationNPC;
|
||||||
|
ConversationPC = p.ConversationPC;
|
||||||
|
ConversationNPCAngle = p.ConversationNPCAngle;
|
||||||
|
ConversationFaceTalker = p.ConversationFaceTalker;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
// This function supplements the pointer cleanup in dobject.cpp, because
|
// This function supplements the pointer cleanup in dobject.cpp, because
|
||||||
// player_t is not derived from DObject. (I tried it, and DestroyScan was
|
// player_t is not derived from DObject. (I tried it, and DestroyScan was
|
||||||
// unable to properly determine the player object's type--possibly
|
// unable to properly determine the player object's type--possibly
|
||||||
|
|
|
@ -1,64 +0,0 @@
|
||||||
// Emacs style mode select -*- C++ -*-
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// $Id:$
|
|
||||||
//
|
|
||||||
// Copyright (C) 1993-1996 by id Software, Inc.
|
|
||||||
//
|
|
||||||
// This source is available for distribution and/or modification
|
|
||||||
// only under the terms of the DOOM Source Code License as
|
|
||||||
// published by id Software. All rights reserved.
|
|
||||||
//
|
|
||||||
// The source is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
|
|
||||||
// for more details.
|
|
||||||
//
|
|
||||||
// DESCRIPTION:
|
|
||||||
// System specific interface stuff.
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef __I_VIDEO_H__
|
|
||||||
#define __I_VIDEO_H__
|
|
||||||
|
|
||||||
#include "basictypes.h"
|
|
||||||
|
|
||||||
class DCanvas;
|
|
||||||
|
|
||||||
// [RH] Set the display mode
|
|
||||||
void I_SetMode (int &width, int &height, int &bits);
|
|
||||||
|
|
||||||
// Takes full 8 bit values.
|
|
||||||
void I_SetPalette (DWORD *palette);
|
|
||||||
|
|
||||||
void I_BeginUpdate (void); // [RH] Locks screen[0]
|
|
||||||
void I_FinishUpdate (void);
|
|
||||||
void I_FinishUpdateNoBlit (void);
|
|
||||||
|
|
||||||
// Wait for vertical retrace or pause a bit.
|
|
||||||
void I_WaitVBL(int count);
|
|
||||||
|
|
||||||
void I_ReadScreen (BYTE *scr);
|
|
||||||
|
|
||||||
bool I_CheckResolution (int width, int height, int bits);
|
|
||||||
void I_ClosestResolution (int *width, int *height, int bits);
|
|
||||||
bool I_SetResolution (int width, int height, int bits);
|
|
||||||
|
|
||||||
bool I_AllocateScreen (DCanvas *canvas, int width, int height, int bits);
|
|
||||||
void I_FreeScreen (DCanvas *canvas);
|
|
||||||
|
|
||||||
void I_LockScreen (DCanvas *canvas);
|
|
||||||
void I_UnlockScreen (DCanvas *canvas);
|
|
||||||
void I_Blit (DCanvas *from, int srcx, int srcy, int srcwidth, int srcheight,
|
|
||||||
DCanvas *to, int destx, int desty, int destwidth, int destheight);
|
|
||||||
|
|
||||||
enum EDisplayType
|
|
||||||
{
|
|
||||||
DISPLAY_WindowOnly,
|
|
||||||
DISPLAY_FullscreenOnly,
|
|
||||||
DISPLAY_Both
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // __I_VIDEO_H__
|
|
|
@ -87,6 +87,10 @@ EXTERN_CVAR (Bool, cl_capfps)
|
||||||
|
|
||||||
CVAR (Int, vid_displaybits, 8, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
CVAR (Int, vid_displaybits, 8, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
||||||
|
|
||||||
|
// vid_asyncblit needs a restart to work. SDL doesn't seem to change if the
|
||||||
|
// frame buffer is changed at run time.
|
||||||
|
CVAR (Bool, vid_asyncblit, 1, CVAR_NOINITCALL|CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
||||||
|
|
||||||
CUSTOM_CVAR (Float, rgamma, 1.f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
CUSTOM_CVAR (Float, rgamma, 1.f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
||||||
{
|
{
|
||||||
if (screen != NULL)
|
if (screen != NULL)
|
||||||
|
@ -301,9 +305,8 @@ SDLFB::SDLFB (int width, int height, bool fullscreen)
|
||||||
UpdatePending = false;
|
UpdatePending = false;
|
||||||
NotPaletted = false;
|
NotPaletted = false;
|
||||||
FlashAmount = 0;
|
FlashAmount = 0;
|
||||||
|
|
||||||
Screen = SDL_SetVideoMode (width, height, vid_displaybits,
|
Screen = SDL_SetVideoMode (width, height, vid_displaybits,
|
||||||
SDL_HWSURFACE|SDL_HWPALETTE|SDL_DOUBLEBUF|SDL_ANYFORMAT|
|
(vid_asyncblit ? SDL_ASYNCBLIT : 0)|SDL_HWSURFACE|SDL_HWPALETTE|SDL_DOUBLEBUF|SDL_ANYFORMAT|
|
||||||
(fullscreen ? SDL_FULLSCREEN : 0));
|
(fullscreen ? SDL_FULLSCREEN : 0));
|
||||||
|
|
||||||
if (Screen == NULL)
|
if (Screen == NULL)
|
||||||
|
|
|
@ -1404,7 +1404,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomPunch)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!PuffType) PuffType = PClass::FindClass(NAME_BulletPuff);
|
if (!PuffType) PuffType = PClass::FindClass(NAME_BulletPuff);
|
||||||
int puffFlags = LAF_ISMELEEATTACK | (flags & CPF_NORANDOMPUFFZ)? LAF_NORANDOMPUFFZ : 0;
|
int puffFlags = LAF_ISMELEEATTACK | ((flags & CPF_NORANDOMPUFFZ) ? LAF_NORANDOMPUFFZ : 0);
|
||||||
|
|
||||||
P_LineAttack (self, angle, Range, pitch, Damage, NAME_Melee, PuffType, puffFlags, &linetarget, &actualdamage);
|
P_LineAttack (self, angle, Range, pitch, Damage, NAME_Melee, PuffType, puffFlags, &linetarget, &actualdamage);
|
||||||
|
|
||||||
|
@ -1426,7 +1426,6 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomPunch)
|
||||||
|
|
||||||
if (flags & CPF_PULLIN) self->flags |= MF_JUSTATTACKED;
|
if (flags & CPF_PULLIN) self->flags |= MF_JUSTATTACKED;
|
||||||
if (flags & CPF_DAGGER) P_DaggerAlert (self, linetarget);
|
if (flags & CPF_DAGGER) P_DaggerAlert (self, linetarget);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -93,12 +93,10 @@ const char *GetVersionString();
|
||||||
#define FORUM_URL "http://forum.drdteam.org"
|
#define FORUM_URL "http://forum.drdteam.org"
|
||||||
#define BUGS_FORUM_URL "http://forum.drdteam.org/viewforum.php?f=24"
|
#define BUGS_FORUM_URL "http://forum.drdteam.org/viewforum.php?f=24"
|
||||||
|
|
||||||
#ifdef __unix__
|
#if defined(__APPLE__) || defined(_WIN32)
|
||||||
#define GAME_DIR ".config/gzdoom"
|
|
||||||
#elif defined(__APPLE__)
|
|
||||||
#define GAME_DIR GAMENAME
|
#define GAME_DIR GAMENAME
|
||||||
#else
|
#else
|
||||||
#define CDROM_DIR "C:\\GZDOOMDAT"
|
#define GAME_DIR ".config/gzdoom"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,7 @@ typedef enum
|
||||||
|
|
||||||
CVAR (Bool, wi_percents, true, CVAR_ARCHIVE)
|
CVAR (Bool, wi_percents, true, CVAR_ARCHIVE)
|
||||||
CVAR (Bool, wi_showtotaltime, true, CVAR_ARCHIVE)
|
CVAR (Bool, wi_showtotaltime, true, CVAR_ARCHIVE)
|
||||||
CVAR (Bool, wi_noautostartmap, false, CVAR_ARCHIVE)
|
CVAR (Bool, wi_noautostartmap, false, CVAR_USERINFO|CVAR_ARCHIVE)
|
||||||
|
|
||||||
|
|
||||||
void WI_loadData ();
|
void WI_loadData ();
|
||||||
|
@ -1098,11 +1098,28 @@ void WI_updateNoState ()
|
||||||
{
|
{
|
||||||
WI_updateAnimatedBack();
|
WI_updateAnimatedBack();
|
||||||
|
|
||||||
|
if (acceleratestage)
|
||||||
|
{
|
||||||
|
cnt = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bool noauto = noautostartmap;
|
||||||
|
|
||||||
if (!wi_noautostartmap && !noautostartmap) cnt--;
|
for (int i = 0; !noauto && i < MAXPLAYERS; ++i)
|
||||||
if (acceleratestage) cnt=0;
|
{
|
||||||
|
if (playeringame[i])
|
||||||
|
{
|
||||||
|
noauto |= players[i].userinfo.GetNoAutostartMap();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!noauto)
|
||||||
|
{
|
||||||
|
cnt--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (cnt==0)
|
if (cnt == 0)
|
||||||
{
|
{
|
||||||
WI_End();
|
WI_End();
|
||||||
G_WorldDone();
|
G_WorldDone();
|
||||||
|
|
|
@ -27,8 +27,8 @@ ACTOR ExplosiveBarrel 2035
|
||||||
BEXP C 5 BRIGHT
|
BEXP C 5 BRIGHT
|
||||||
BEXP D 5 BRIGHT A_Explode
|
BEXP D 5 BRIGHT A_Explode
|
||||||
BEXP E 10 BRIGHT
|
BEXP E 10 BRIGHT
|
||||||
BEXP E 1050 BRIGHT A_BarrelDestroy
|
TNT1 A 1050 BRIGHT A_BarrelDestroy
|
||||||
BEXP E 5 A_Respawn
|
TNT1 A 5 A_Respawn
|
||||||
Wait
|
Wait
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -710,6 +710,10 @@
|
||||||
RelativePath=".\src\m_random.cpp"
|
RelativePath=".\src\m_random.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\m_specialpaths.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\src\md5.cpp"
|
RelativePath=".\src\md5.cpp"
|
||||||
>
|
>
|
||||||
|
|
Loading…
Reference in a new issue