Merge branch 'master' into scripting

Conflicts:
	src/g_shared/a_randomspawner.cpp
	src/g_strife/a_strifeweapons.cpp
	src/thingdef/thingdef_parse.cpp
	wadsrc/static/actors/constants.txt
This commit is contained in:
Christoph Oelckers 2013-09-03 09:01:28 +02:00
commit 251cdacf26
30 changed files with 168 additions and 57 deletions

View file

@ -44,7 +44,7 @@
#define DUMB_VERSION_STR "0.9.3"
#define DUMB_NAME "DUMB v"DUMB_VERSION_STR
#define DUMB_NAME "DUMB v" DUMB_VERSION_STR
#define DUMB_YEAR 2005
#define DUMB_MONTH 8
@ -56,13 +56,13 @@
#define DUMB_DAY_STR1 "7"
#if DUMB_MONTH < 10
#define DUMB_MONTH_STR2 "0"DUMB_MONTH_STR1
#define DUMB_MONTH_STR2 "0" DUMB_MONTH_STR1
#else
#define DUMB_MONTH_STR2 DUMB_MONTH_STR1
#endif
#if DUMB_DAY < 10
#define DUMB_DAY_STR2 "0"DUMB_DAY_STR1
#define DUMB_DAY_STR2 "0" DUMB_DAY_STR1
#else
#define DUMB_DAY_STR2 DUMB_DAY_STR1
#endif
@ -74,7 +74,7 @@
*/
#define DUMB_DATE (DUMB_YEAR*10000 + DUMB_MONTH*100 + DUMB_DAY)
#define DUMB_DATE_STR DUMB_DAY_STR1"."DUMB_MONTH_STR1"."DUMB_YEAR_STR4
#define DUMB_DATE_STR DUMB_DAY_STR1 "." DUMB_MONTH_STR1 "." DUMB_YEAR_STR4
#undef MIN

View file

@ -650,8 +650,8 @@ static DUMB_IT_SIGDATA *it_mod_load_sigdata(DUMBFILE *f, int rstrict)
if ( ( rstrict & 2 ) )
{
long total_sample_size;
long remain;
int32 total_sample_size;
int32 remain;
rem = f;
f = dumbfile_buffer_mod_2(rem, sigdata->n_samples, sigdata->sample, &total_sample_size, &remain);
if (!f) {

View file

@ -436,7 +436,7 @@ static int limit_xm_getc(void *f)
static long limit_xm_getnc(char *ptr, int32 n, void *f)
static int32 limit_xm_getnc(char *ptr, int32 n, void *f)
{
LIMITED_XM *lx = f;
int left;

View file

@ -2657,10 +2657,11 @@ void AM_drawThings ()
if (texture == NULL) goto drawTriangle; // fall back to standard display if no sprite can be found.
const fixed_t spriteScale = 10 * scale_mtof;
const fixed_t spriteXScale = FixedMul(t->scaleX, 10 * scale_mtof);
const fixed_t spriteYScale = FixedMul(t->scaleY, 10 * scale_mtof);
DrawMarker (texture, p.x, p.y, 0, !!(frame->Flip & (1 << rotation)),
spriteScale, spriteScale, 0, FRACUNIT, 0, LegacyRenderStyles[STYLE_Normal]);
spriteXScale, spriteYScale, t->Translation, FRACUNIT, 0, LegacyRenderStyles[STYLE_Normal]);
}
else
{

View file

@ -541,7 +541,7 @@ CCMD (mapchecksum)
}
for (int i = 1; i < argv.argc(); ++i)
{
map = P_OpenMapData(argv[i]);
map = P_OpenMapData(argv[i], true);
if (map == NULL)
{
Printf("Cannot load %s as a map\n", argv[i]);

View file

@ -73,7 +73,6 @@ static FRandom pr_script("FScript");
#define AngleToFixed(x) ((((double) x) / ((double) ANG45/45)) * FRACUNIT)
#define FixedToAngle(x) ((((double) x) / FRACUNIT) * ANG45/45)
#define FIXED_TO_FLOAT(f) ((f)/(float)FRACUNIT)
// functions. FParser::SF_ means Script Function not, well.. heh, me
@ -1417,11 +1416,11 @@ void FParser::SF_PointToDist(void)
if (CheckArgs(4))
{
// Doing this in floating point is actually faster with modern computers!
float x = floatvalue(t_argv[2]) - floatvalue(t_argv[0]);
float y = floatvalue(t_argv[3]) - floatvalue(t_argv[1]);
double x = floatvalue(t_argv[2]) - floatvalue(t_argv[0]);
double y = floatvalue(t_argv[3]) - floatvalue(t_argv[1]);
t_return.type = svt_fixed;
t_return.value.f = (fixed_t)(sqrtf(x*x+y*y)*65536.f);
t_return.value.f = FLOAT2FIXED(sqrt(x*x+y*y)*65536.f);
}
}

View file

@ -110,7 +110,7 @@ struct svalue_t
int intvalue(const svalue_t & v);
fixed_t fixedvalue(const svalue_t & v);
float floatvalue(const svalue_t & v);
double floatvalue(const svalue_t & v);
const char *stringvalue(const svalue_t & v);
AActor *actorvalue(const svalue_t &svalue);

View file

@ -89,11 +89,12 @@ fixed_t fixedvalue(const svalue_t &v)
//
//==========================================================================
float floatvalue(const svalue_t &v)
double floatvalue(const svalue_t &v)
{
return (float)( (v.type == svt_string ? atof(v.string) :
v.type == svt_fixed ? (float)(v.value.f / (float)FRACUNIT) :
v.type == svt_mobj ? -1.f : (float)v.value.i ));
return
v.type == svt_string ? atof(v.string) :
v.type == svt_fixed ? FIXED2DBL(v.value.f) :
v.type == svt_mobj ? -1. : (double)v.value.i;
}
//==========================================================================

View file

@ -1923,7 +1923,7 @@ CCMD(listmaps)
for(unsigned i = 0; i < wadlevelinfos.Size(); i++)
{
level_info_t *info = &wadlevelinfos[i];
MapData *map = P_OpenMapData(info->mapname);
MapData *map = P_OpenMapData(info->mapname, true);
if (map != NULL)
{

View file

@ -154,8 +154,9 @@ class ARandomSpawner : public AActor
newmobj->args[4] = args[4];
newmobj->special1 = special1;
newmobj->special2 = special2;
newmobj->SpawnFlags = SpawnFlags;
newmobj->SpawnFlags = SpawnFlags & ~MTF_SECRET; // MTF_SECRET needs special treatment to avoid incrementing the secret counter twice. It had already been processed for the spawner itself.
newmobj->HandleSpawnFlags();
newmobj->SpawnFlags = SpawnFlags;
newmobj->tid = tid;
newmobj->AddToHash();
newmobj->velx = velx;

View file

@ -140,18 +140,40 @@ DEFINE_ACTION_FUNCTION(AActor, A_JabDagger)
//
//============================================================================
enum
{
AMF_TARGETEMITTER = 1,
AMF_TARGETNONPLAYER = 2,
AMF_EMITFROMTARGET = 4,
};
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_AlertMonsters)
{
PARAM_ACTION_PROLOGUE;
PARAM_FIXED_OPT(maxdist) { maxdist = 0; }
PARAM_INT_OPT(Flags) { Flags = 0; }
if (self->player != NULL)
AActor * target = NULL;
AActor * emitter = self;
if (self->player != NULL || (Flags & AMF_TARGETEMITTER))
{
P_NoiseAlert(self, self, false, maxdist);
target = self;
}
else if (self->target != NULL && (Flags & AMF_TARGETNONPLAYER))
{
target = self->target;
}
else if (self->target != NULL && self->target->player != NULL)
{
P_NoiseAlert (self->target, self, false, maxdist);
target = self->target;
}
if (Flags & AMF_EMITFROMTARGET) emitter = target;
if (target != NULL && emitter != NULL)
{
P_NoiseAlert(target, emitter, false, maxdist);
}
return 0;
}

View file

@ -35,6 +35,7 @@
#include <string.h>
#include "m_argv.h"
#include "cmdlib.h"
#include "i_system.h"
IMPLEMENT_CLASS (DArgs)
@ -391,6 +392,14 @@ void DArgs::CollectFiles(const char *param, const char *extension)
}
}
// Optional: Replace short path names with long path names
#ifdef _WIN32
for (i = 0; i < work.Size(); ++i)
{
work[i] = I_GetLongPathName(work[i]);
}
#endif
// Step 3: Add work back to Argv, as long as it's non-empty.
if (work.Size() > 0)
{

View file

@ -12,7 +12,7 @@
#include <stdlib.h>
#include "doomtype.h"
#if defined(__GNUC__) && defined(__i386__)
#if defined(__GNUC__) && defined(__i386__) && !defined(__clang__)
#include "gccinlines.h"
#elif defined(_MSC_VER) && defined(_M_IX86)
#include "mscinlines.h"

View file

@ -575,11 +575,7 @@ int ACSStringPool::InsertString(FString &str, unsigned int h, unsigned int bucke
}
else
{ // Scan for the next free entry
unsigned int i;
for (i = FirstFreeEntry + 1; i < Pool.Size() && Pool[i].Next != FREE_ENTRY; ++i)
{
}
FirstFreeEntry = i;
FindFirstFreeEntry(FirstFreeEntry + 1);
}
PoolEntry *entry = &Pool[index];
entry->Str = str;
@ -590,6 +586,23 @@ int ACSStringPool::InsertString(FString &str, unsigned int h, unsigned int bucke
return index | STRPOOL_LIBRARYID_OR;
}
//============================================================================
//
// ACSStringPool :: FindFirstFreeEntry
//
// Finds the first free entry, starting at base.
//
//============================================================================
void ACSStringPool::FindFirstFreeEntry(unsigned base)
{
while (base < Pool.Size() && Pool[base].Next != FREE_ENTRY)
{
base++;
}
FirstFreeEntry = base;
}
//============================================================================
//
// ACSStringPool :: ReadStrings
@ -638,6 +651,7 @@ void ACSStringPool::ReadStrings(PNGHandle *png, DWORD id)
{
delete[] str;
}
FindFirstFreeEntry(0);
}
}
@ -690,6 +704,7 @@ void ACSStringPool::Dump() const
Printf("%4u. (%2d) \"%s\"\n", i, Pool[i].LockCount, Pool[i].Str.GetChars());
}
}
Printf("First free %u\n", FirstFreeEntry);
}
//============================================================================
@ -8397,7 +8412,7 @@ scriptwait:
{
int playernum = STACK(1);
if (playernum < 0 || playernum >= MAXPLAYERS || !playeringame[playernum] || players[playernum].camera == NULL)
if (playernum < 0 || playernum >= MAXPLAYERS || !playeringame[playernum] || players[playernum].camera == NULL || players[playernum].camera->player != NULL)
{
STACK(1) = -1;
}

View file

@ -100,6 +100,7 @@ public:
private:
int FindString(const char *str, size_t len, unsigned int h, unsigned int bucketnum);
int InsertString(FString &str, unsigned int h, unsigned int bucketnum, const SDWORD *stack, int stackdepth);
void FindFirstFreeEntry(unsigned int base);
enum { NUM_BUCKETS = 251 };
enum { FREE_ENTRY = 0xFFFFFFFE }; // Stored in PoolEntry's Next field

View file

@ -752,7 +752,10 @@ public:
{
ReplyText = GStrings(ReplyText + 1);
}
FBrokenLines *ReplyLines = V_BreakLines (SmallFont, 320-50-10, ReplyText);
FString ReplyString = ReplyText;
if (reply->NeedsGold) ReplyString.AppendFormat(" for %u", reply->ItemCheck[0].Amount);
FBrokenLines *ReplyLines = V_BreakLines (SmallFont, 320-50-10, ReplyString);
mResponses.Push(mResponseLines.Size());
for (j = 0; ReplyLines[j].Width >= 0; ++j)

View file

@ -53,11 +53,6 @@
#include "r_data/r_translate.h"
#include "g_level.h"
#define WATER_SINK_FACTOR 3
#define WATER_SINK_SMALL_FACTOR 4
#define WATER_SINK_SPEED (FRACUNIT/2)
#define WATER_JUMP_SPEED (FRACUNIT*7/2)
CVAR (Bool, cl_bloodsplats, true, CVAR_ARCHIVE)
CVAR (Int, sv_smartaim, 0, CVAR_ARCHIVE|CVAR_SERVERINFO)
CVAR (Bool, cl_doautoaim, false, CVAR_ARCHIVE)

View file

@ -4105,8 +4105,12 @@ void AActor::HandleSpawnFlags ()
}
if (SpawnFlags & MTF_SECRET)
{
//Printf("Secret %s in sector %i!\n", GetTag(), Sector->sectornum);
flags5 |= MF5_COUNTSECRET;
if (!(flags5 & MF5_COUNTSECRET))
{
//Printf("Secret %s in sector %i!\n", GetTag(), Sector->sectornum);
flags5 |= MF5_COUNTSECRET;
level.total_secrets++;
}
}
}

View file

@ -250,7 +250,7 @@ static int GetMapIndex(const char *mapname, int lastindex, const char *lumpname,
//
//===========================================================================
MapData *P_OpenMapData(const char * mapname)
MapData *P_OpenMapData(const char * mapname, bool justcheck)
{
MapData * map = new MapData;
FileReader * wadReader = NULL;
@ -331,13 +331,18 @@ MapData *P_OpenMapData(const char * mapname)
const char * lumpname = Wads.GetLumpFullName(lump_name + i);
try
{
index = GetMapIndex(mapname, index, lumpname, true);
index = GetMapIndex(mapname, index, lumpname, !justcheck);
}
catch(...)
{
delete map;
throw;
}
if (index == -2)
{
delete map;
return NULL;
}
if (index == ML_BEHAVIOR) map->HasBehavior = true;
// The next lump is not part of this map anymore
@ -471,13 +476,18 @@ MapData *P_OpenMapData(const char * mapname)
{
try
{
index = GetMapIndex(maplabel, index, lumpname, true);
index = GetMapIndex(maplabel, index, lumpname, !justcheck);
}
catch(...)
{
delete map;
throw;
}
if (index == -2)
{
delete map;
return NULL;
}
if (index == ML_BEHAVIOR) map->HasBehavior = true;
// The next lump is not part of this map anymore
@ -508,7 +518,7 @@ MapData *P_OpenMapData(const char * mapname)
bool P_CheckMapData(const char *mapname)
{
MapData *mapd = P_OpenMapData(mapname);
MapData *mapd = P_OpenMapData(mapname, true);
if (mapd == NULL) return false;
delete mapd;
return true;
@ -3607,7 +3617,7 @@ void P_SetupLevel (char *lumpname, int position)
P_FreeLevelData ();
interpolator.ClearInterpolations(); // [RH] Nothing to interpolate on a fresh level.
MapData *map = P_OpenMapData(lumpname);
MapData *map = P_OpenMapData(lumpname, true);
if (map == NULL)
{
I_Error("Unable to open map '%s'\n", lumpname);

View file

@ -94,7 +94,7 @@ struct MapData
void GetChecksum(BYTE cksum[16]);
};
MapData * P_OpenMapData(const char * mapname);
MapData * P_OpenMapData(const char * mapname, bool justcheck);
bool P_CheckMapData(const char * mapname);

View file

@ -220,7 +220,6 @@ class USDFParser : public UDMFParserBase
if (reply->ItemCheck.Size() > 0)
{
if (reply->ItemCheck[0].Amount <= 0) reply->NeedsGold = false;
if (reply->NeedsGold) ReplyString.AppendFormat(" for %u", reply->ItemCheck[0].Amount);
}
reply->Reply = ncopystring(ReplyString);

View file

@ -699,7 +699,7 @@ bool I_WriteIniFailed ()
static const char *pattern;
#ifdef __APPLE__
#if defined(__APPLE__) && !defined(__llvm__)
static int matchfile (struct dirent *ent)
#else
static int matchfile (const struct dirent *ent)

View file

@ -463,7 +463,7 @@ void STAT_ChangeLevel(const char *newl)
{
// we reached the end of this episode
int wad = 0;
MapData * map = P_OpenMapData(StartEpisode->mEpisodeMap);
MapData * map = P_OpenMapData(StartEpisode->mEpisodeMap, false);
if (map != NULL)
{
wad = Wads.GetLumpFile(map->lumpnum);

View file

@ -233,13 +233,13 @@ FMultiPatchTexture::FMultiPatchTexture (const void *texdef, FPatchLookup *patchl
NumParts = SAFESHORT(mtexture.d->patchcount);
}
if (NumParts <= 0)
if (NumParts < 0)
{
I_FatalError ("Bad texture directory");
}
UseType = FTexture::TEX_Wall;
Parts = new TexPart[NumParts];
Parts = NumParts > 0 ? new TexPart[NumParts] : NULL;
Width = SAFESHORT(mtexture.d->width);
Height = SAFESHORT(mtexture.d->height);
strncpy (Name, (const char *)mtexture.d->name, 8);
@ -906,7 +906,7 @@ void FTextureManager::AddTexturesLump (const void *lumpdata, int lumpsize, int d
// There is bizzarely a Doom editing tool that writes to the
// first two elements of columndirectory, so I can't check those.
if (SAFESHORT(tex->patchcount) <= 0 ||
if (SAFESHORT(tex->patchcount) < 0 ||
tex->columndirectory[2] != 0 ||
tex->columndirectory[3] != 0)
{

View file

@ -5189,6 +5189,18 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetTics)
PARAM_ACTION_PROLOGUE;
PARAM_INT(tics_to_set);
if (stateowner != self && self->player != NULL && stateowner->IsKindOf(RUNTIME_CLASS(AWeapon)))
{ // Is this a weapon? Need to check psp states for a match, then. Blah.
for (int i = 0; i < NUMPSPRITES; ++i)
{
if (self->player->psprites[i].state == callingstate)
{
self->player->psprites[i].tics = tics_to_set;
return 0;
}
}
}
// Just set tics for self.
self->tics = tics_to_set;
return 0;
}

View file

@ -898,7 +898,7 @@ static void ParseActorProperty(FScanner &sc, Baggage &bag)
static void ParseActionDef (FScanner &sc, PClassActor *cls)
{
bool error = false;
unsigned int error = 0;
const AFuncDesc *afd;
FName funcname;
TArray<PType *> rets;
@ -907,8 +907,8 @@ static void ParseActionDef (FScanner &sc, PClassActor *cls)
if (sc.LumpNum == -1 || Wads.GetLumpFile(sc.LumpNum) > 0)
{
sc.ScriptMessage ("action functions can only be imported by internal class and actor definitions!");
error++;
sc.ScriptMessage ("Action functions can only be imported by internal class and actor definitions!");
++error;
}
sc.MustGetToken(TK_Native);
@ -923,7 +923,7 @@ static void ParseActionDef (FScanner &sc, PClassActor *cls)
if (afd == NULL)
{
sc.ScriptMessage ("The function '%s' has not been exported from the executable.", sc.String);
error++;
++error;
}
args.Push(NewClassPointer(cls)), argflags.Push(0); // implied self pointer
args.Push(NewClassPointer(RUNTIME_CLASS(AActor))), argflags.Push(0); // implied stateowner pointer
@ -1028,7 +1028,7 @@ static void ParseActionDef (FScanner &sc, PClassActor *cls)
sym->Flags = VARF_Method | VARF_Action;
if (error)
{
FScriptPosition::ErrorCounter++;
FScriptPosition::ErrorCounter += error;
}
else if (cls->Symbols.AddSymbol(sym) == NULL)
{

View file

@ -1569,3 +1569,31 @@ unsigned int I_MakeRNGSeed()
CryptReleaseContext(prov, 0);
return seed;
}
//==========================================================================
//
// I_GetLongPathName
//
// Returns the long version of the path, or the original if there isn't
// anything worth changing.
//
//==========================================================================
FString I_GetLongPathName(FString shortpath)
{
DWORD buffsize = GetLongPathName(shortpath.GetChars(), NULL, 0);
if (buffsize == 0)
{ // nothing to change (it doesn't exist, maybe?)
return shortpath;
}
TCHAR *buff = new TCHAR[buffsize];
DWORD buffsize2 = GetLongPathName(shortpath.GetChars(), buff, buffsize);
if (buffsize2 >= buffsize)
{ // Failure! Just return the short path
delete[] buff;
return shortpath;
}
FString longpath(buff, buffsize2);
delete[] buff;
return longpath;
}

View file

@ -155,6 +155,9 @@ typedef _W64 long WLONG_PTR;
typedef long WLONG_PTR;
#endif
// Wrapper for GetLongPathName
FString I_GetLongPathName(FString shortpath);
// Directory searching routines
// Mirror WIN32_FIND_DATAA in <winbase.h>

View file

@ -180,7 +180,7 @@ ACTOR Actor native //: Thinker
action native A_TurretLook();
action native A_KlaxonBlare();
action native A_Countdown();
action native A_AlertMonsters(float maxdist = 0);
action native A_AlertMonsters(float maxdist = 0, int flags = 0);
action native A_ClearSoundTarget();
action native A_FireAssaultGun();
action native A_CheckTerrain();

View file

@ -347,3 +347,11 @@ enum
CLOFF_SKIPOBSTACLES = CLOFF_SKIPENEMY|CLOFF_SKIPFRIEND|CLOFF_SKIPOBJECT|CLOFF_SKIPNONHOSTILE,
CLOFF_NOAIM = CLOFF_NOAIM_VERT|CLOFF_NOAIM_HORZ
};
// Flags for A_AlertMonsters
const int AMF_TARGETEMITTER = 1;
const int AMF_TARGETNONPLAYER = 2;
const int AMF_EMITFROMTARGET = 4;