- Fixed: CopyPlayer() in p_saveg.cpp should use normal assignment, not

memcpy to copy the player structures.
- Fixed compilation with MinGW again and removed most of the new warnings.

And following is the log that I forgot to paste in for the previous commit:

- Changed the memory management for FString. Instead of using a garbage
  collected heap, it now uses normal heap calls and reference counting to
  implement lazy copying. You may now use bitwise operators to move
  (but not copy!) FStrings around in memory. This means that the
  CopyForTArray template function is gone, since TArrays can now freely
  move their contents around without bothering with their specifics.
  
  There is one important caveat, however. It is not acceptable to blindly 0
  an FString's contents. This necessitated the creation of a proper
  constructor for player_s so that it can be reset without using memset. I
  did a quick scan of all memsets in the source and didn't see anything else
  with a similar problem, but it's possible I missed something.
- Fixed: Build tiles were never deallocated.
- Fixed: Using Build's palette.dat only got half the palette right.


SVN r117 (trunk)
This commit is contained in:
Randy Heit 2006-05-16 04:19:20 +00:00
parent ac53ed6ecd
commit 6cd1e2ce6a
24 changed files with 81 additions and 91 deletions

View file

@ -31,9 +31,9 @@ cleanexe:
clean:
@$(MAKE) -C tools/lemon -f Makefile.mgw clean
@$(MAKE) -C tools/re2c -f Makefile.mgw clean
@$(MAKE) -C tools/dehsupp -f Makefile.mgw clean
@$(MAKE) -C tools/makewad -f Makefile.mgw clean
@$(MAKE) -C tools/xlatcc -f Makefile.mgw clean
@$(MAKE) -C tools/dehsupp -f Makefile clean
@$(MAKE) -C tools/makewad -f Makefile clean
@$(MAKE) -C tools/xlatcc -f Makefile clean
@$(MAKE) -C wadsrc -f Makefile.mgw clean
@$(MAKE) -C . -f Makefile.mingw clean
@$(MAKE) -C zlib -f Makefile.mgw clean

View file

@ -90,6 +90,7 @@ OBJECTS += \
$(OBJDIR)/decallib.o \
$(OBJDIR)/decorations.o \
$(OBJDIR)/dobject.o \
$(OBJDIR)/dobjtype.o \
$(OBJDIR)/doomdef.o \
$(OBJDIR)/doomstat.o \
$(OBJDIR)/dsectoreffect.o \
@ -190,7 +191,6 @@ OBJECTS += \
$(OBJDIR)/vectors.o \
$(OBJDIR)/name.o \
$(OBJDIR)/zstring.o \
$(OBJDIR)/zstringpool.o \
$(OBJDIR)/zstrformat.o \
$(OBJDIR)/w_wad.o \
$(OBJDIR)/wi_stuff.o \
@ -201,12 +201,8 @@ OBJECTS += \
$(OBJDIR)/a_cacodemon.o \
$(OBJDIR)/a_cyberdemon.o \
$(OBJDIR)/a_demon.o \
$(OBJDIR)/a_doomarmor.o \
$(OBJDIR)/a_doomartifacts.o \
$(OBJDIR)/a_doomdecorations.o \
$(OBJDIR)/a_doomhealth.o \
$(OBJDIR)/a_doomimp.o \
$(OBJDIR)/a_doomkeys.o \
$(OBJDIR)/a_doommisc.o \
$(OBJDIR)/a_doomplayer.o \
$(OBJDIR)/a_doomweaps.o \
@ -223,9 +219,7 @@ OBJECTS += \
$(OBJDIR)/a_chicken.o \
$(OBJDIR)/a_clink.o \
$(OBJDIR)/a_dsparil.o \
$(OBJDIR)/a_hereticarmor.o \
$(OBJDIR)/a_hereticartifacts.o \
$(OBJDIR)/a_hereticdecorations.o \
$(OBJDIR)/a_hereticimp.o \
$(OBJDIR)/a_heretickeys.o \
$(OBJDIR)/a_hereticmisc.o \
@ -257,14 +251,10 @@ OBJECTS += \
$(OBJDIR)/a_fighterplayer.o \
$(OBJDIR)/a_fighterquietus.o \
$(OBJDIR)/a_firedemon.o \
$(OBJDIR)/a_flame.o \
$(OBJDIR)/a_flechette.o \
$(OBJDIR)/a_fog.o \
$(OBJDIR)/a_healingradius.o \
$(OBJDIR)/a_heresiarch.o \
$(OBJDIR)/a_hexenarmor.o \
$(OBJDIR)/a_hexendecorations.o \
$(OBJDIR)/a_hexenkeys.o \
$(OBJDIR)/a_hexenspecialdecs.o \
$(OBJDIR)/a_iceguy.o \
$(OBJDIR)/a_korax.o \
@ -277,9 +267,7 @@ OBJECTS += \
$(OBJDIR)/a_mana.o \
$(OBJDIR)/a_pig.o \
$(OBJDIR)/a_puzzleitems.o \
$(OBJDIR)/a_scriptprojectiles.o \
$(OBJDIR)/a_serpent.o \
$(OBJDIR)/a_speedboots.o \
$(OBJDIR)/a_spike.o \
$(OBJDIR)/a_summon.o \
$(OBJDIR)/a_teleportother.o \
@ -291,39 +279,29 @@ OBJECTS += \
$(OBJDIR)/a_artitele.o \
$(OBJDIR)/a_minotaur.o \
$(OBJDIR)/a_ravenambient.o \
$(OBJDIR)/a_ravenartifacts.o \
$(OBJDIR)/a_ravenhealth.o \
$(OBJDIR)/a_acolyte.o \
$(OBJDIR)/a_alienspectres.o \
$(OBJDIR)/a_beggars.o \
$(OBJDIR)/a_coin.o \
$(OBJDIR)/a_crusader.o \
$(OBJDIR)/a_entityboss.o \
$(OBJDIR)/a_inquisitor.o \
$(OBJDIR)/a_loremaster.o \
$(OBJDIR)/a_macil.o \
$(OBJDIR)/a_merchants.o \
$(OBJDIR)/a_oracle.o \
$(OBJDIR)/a_peasant.o \
$(OBJDIR)/a_programmer.o \
$(OBJDIR)/a_questitems.o \
$(OBJDIR)/a_ratbuddy.o \
$(OBJDIR)/a_reaver.o \
$(OBJDIR)/a_rebels.o \
$(OBJDIR)/a_sentinel.o \
$(OBJDIR)/a_spectral.o \
$(OBJDIR)/a_stalker.o \
$(OBJDIR)/a_strifeammo.o \
$(OBJDIR)/a_strifearmor.o \
$(OBJDIR)/a_strifebishop.o \
$(OBJDIR)/a_strifeitems.o \
$(OBJDIR)/a_strifekeys.o \
$(OBJDIR)/a_strifeplayer.o \
$(OBJDIR)/a_strifestuff.o \
$(OBJDIR)/a_strifeweapons.o \
$(OBJDIR)/a_templar.o \
$(OBJDIR)/a_thingstoblowup.o \
$(OBJDIR)/a_zombie.o \
$(OBJDIR)/strife_sbar.o \
$(OBJDIR)/a_action.o \
$(OBJDIR)/a_artifacts.o \
@ -346,7 +324,6 @@ OBJECTS += \
$(OBJDIR)/a_soundenvironment.o \
$(OBJDIR)/a_soundsequence.o \
$(OBJDIR)/a_spark.o \
$(OBJDIR)/a_splashes.o \
$(OBJDIR)/a_waterzone.o \
$(OBJDIR)/a_weapons.o \
$(OBJDIR)/hudmessages.o \

View file

@ -1,4 +1,7 @@
May 15, 2006
- Fixed: CopyPlayer() in p_saveg.cpp should use normal assignment, not
memcpy to copy the player structures.
- Fixed compilation with MinGW again and removed most of the new warnings.
- Changed the memory management for FString. Instead of using a garbage
collected heap, it now uses normal heap calls and reference counting to
implement lazy copying. You may now use bitwise operators to move

View file

@ -752,10 +752,11 @@ static void AM_initColors (BOOL overlayed)
int red = (int)(backRed * back + foreRed * fore);
int green = (int)(backGreen * back + foreGreen * fore);
int blue = (int)(backGreen * back + foreBlue * fore);
if (palette)
// [RH] What was I thinking here?
// if (palette)
antialias[alias][i] = ColorMatcher.Pick (red, green, blue);
else
antialias[alias][i] = MAKERGB(red, green, blue);
// else
// antialias[alias][i] = MAKERGB(red, green, blue);
}
*(aliasedLines[alias].color) = aliasedLines[alias].falseColor;
}

View file

@ -1971,7 +1971,7 @@ static void C_TabComplete (bool goForward)
}
else
{ // Find the last matching tab, then go one past it.
while (++TabPos < TabCommands.Size())
while (++TabPos < (int)TabCommands.Size())
{
if (FindDiffPoint (TabCommands[TabPos].TabName, (char *)(CmdLine + TabStart)) < TabSize)
{
@ -1986,7 +1986,7 @@ static void C_TabComplete (bool goForward)
}
}
if ((goForward && ++TabPos == TabCommands.Size()) ||
if ((goForward && ++TabPos == (int)TabCommands.Size()) ||
(!goForward && --TabPos < 0))
{
TabbedLast = false;
@ -2022,7 +2022,7 @@ static bool C_TabCompleteList ()
nummatches = 0;
maxwidth = 0;
for (i = TabPos; i < TabCommands.Size(); ++i)
for (i = TabPos; i < (int)TabCommands.Size(); ++i)
{
if (FindDiffPoint (TabCommands[i].TabName, (char *)(CmdLine + TabStart)) < TabSize)
{

View file

@ -1336,7 +1336,7 @@ static int PatchAmmo (int ammoNum)
// Fix per-ammo/max-ammo amounts for descendants of the base ammo class
if (oldclip != *per)
{
for (int i = 0; i < PClass::m_Types.Size(); ++i)
for (unsigned int i = 0; i < PClass::m_Types.Size(); ++i)
{
PClass *type = PClass::m_Types[i];

View file

@ -1559,7 +1559,7 @@ static EIWADType IdentifyVersion (const char *zdoom_wad)
for (i = numwads = 0; i < sizeof(IWADNames)/sizeof(char *); i++)
{
if (wads[i].Path != NULL)
if (!wads[i].Path.IsEmpty())
{
if (i != numwads)
{

View file

@ -295,7 +295,7 @@ CCMD (dumpclasses)
}
};
int i;
unsigned int i;
int shown, omitted;
DumpInfo *tree = NULL;
const PClass *root = NULL;
@ -499,7 +499,7 @@ void DObject::PointerSubstitution (DObject *old, DObject *notOld)
players[i].FixPointers (old, notOld);
}
for (i = 0; i < numsectors; ++i)
for (i = 0; i < (unsigned int)numsectors; ++i)
{
if (sectors[i].SoundTarget == old)
{
@ -582,7 +582,7 @@ void DObject::DestroyScan ()
}
}
for (i = 0; i < numsectors; ++i)
for (i = 0; i < (unsigned int)numsectors; ++i)
{
j = destroycount;
do

View file

@ -628,7 +628,7 @@ FArchive::FArchive (FFile &file)
void FArchive::AttachToFile (FFile &file)
{
int i;
unsigned int i;
m_HubTravel = false;
m_File = &file;
@ -1349,7 +1349,6 @@ const PClass *FArchive::ReadClass ()
~String() { if (val) delete[] val; }
char *val;
} typeName;
int i;
if (m_ClassCount >= PClass::m_Types.Size())
{
@ -1360,7 +1359,7 @@ const PClass *FArchive::ReadClass ()
FName zaname(typeName.val, true);
if (zaname != NAME_None)
{
for (i = 0; i < PClass::m_Types.Size(); i++)
for (unsigned int i = 0; i < PClass::m_Types.Size(); i++)
{
if (PClass::m_Types[i]->TypeName == zaname)
{

View file

@ -80,8 +80,9 @@ EXTERN_CVAR (Float, sv_gravity)
EXTERN_CVAR (Float, sv_aircontrol)
EXTERN_CVAR (Int, disableautosave)
#define lioffset(x) myoffsetof(level_info_t,x)
#define cioffset(x) myoffsetof(cluster_info_t,x)
// Hey, GCC, these macros better be safe!
#define lioffset(x) ((size_t)&((level_info_t*)1)->x - 1)
#define cioffset(x) ((size_t)&((cluster_info_t*)1)->x - 1)
#define SNAP_ID MAKE_ID('s','n','A','p')
#define VIST_ID MAKE_ID('v','i','S','t')

View file

@ -293,7 +293,7 @@ static void ParseLock()
static void ClearLocks()
{
int i;
unsigned int i;
for(i=0;i<PClass::m_Types.Size();i++)
{
if (PClass::m_Types[i]->IsDescendantOf(RUNTIME_CLASS(AKey)))

View file

@ -1171,10 +1171,11 @@ static byte BitTranslate[16];
void M_OptInit (void)
{
int currval = 0, dummy1, dummy2, i;
int dummy1, dummy2;
size_t currval = 0;
char name[24];
for (i = 1; i < 32 && currval < countof(Depths); i++)
for (unsigned int i = 1; i < 32 && currval < countof(Depths); i++)
{
I_StartModeIterator (i);
if (I_NextMode (&dummy1, &dummy2, NULL))
@ -3049,7 +3050,7 @@ CCMD (addmenukey)
void M_Deinit ()
{
// Free bitdepth names for the modes menu.
for (int i = 0; i < countof(Depths); ++i)
for (size_t i = 0; i < countof(Depths); ++i)
{
if (Depths[i].name != NULL)
{

View file

@ -442,7 +442,7 @@ void P_DrawRailTrail (AActor * source, vec3_t start, vec3_t end, int color1, int
// Allow other sounds than 'weapons/railgf'!
if (!source->player) sound = source->AttackSound;
else if (source->player->ReadyWeapon) sound = source->player->ReadyWeapon->AttackSound;
else sound = NULL;
else sound = 0;
if (!sound) sound=S_FindSound("weapons/railgf");
// The railgun's sound is special. It gets played from the

View file

@ -3296,7 +3296,6 @@ void P_SpawnPlayer (mapthing2_t *mthing)
int playernum;
player_t *p;
APlayerPawn *mobj, *oldactor;
int i;
BYTE state;
// [RH] Things 4001-? are also multiplayer starts. Just like 1-4.
@ -3433,7 +3432,7 @@ void P_SpawnPlayer (mapthing2_t *mthing)
// give all cards in death match mode
if (deathmatch)
{
for (i = 0; i < PClass::m_Types.Size(); ++i)
for (unsigned int i = 0; i < PClass::m_Types.Size(); ++i)
{
if (PClass::m_Types[i]->IsDescendantOf (RUNTIME_CLASS(AKey)))
{

View file

@ -122,7 +122,6 @@ static void ReadOnePlayer (FArchive &arc)
{
didIt = true;
player_t playerTemp;
memset (&playerTemp, 0, sizeof(playerTemp));
playerTemp.Serialize (arc);
CopyPlayer (&players[i], &playerTemp, name);
}
@ -227,7 +226,7 @@ static void CopyPlayer (player_t *dst, player_t *src, const char *name)
// The userinfo needs to be saved for real players, but it
// needs to come from the save for bots.
userinfo_t uibackup = dst->userinfo;
memcpy (dst, src, sizeof(player_t));
*dst = *src;
if (dst->isbot)
{

View file

@ -198,36 +198,39 @@ static const char *DamageKeywords[] =
NULL
};
// Alternate offsetof macro to shut GCC up
#define theoffsetof(type,field) ((size_t)&((type*)1)->field - 1)
static FGenericParse SplashParser[] =
{
{ GEN_End, {0} },
{ GEN_Sound, {myoffsetof(FSplashDef, SmallSplashSound)} },
{ GEN_Fixed, {myoffsetof(FSplashDef, SmallSplashClip)} },
{ GEN_Sound, {myoffsetof(FSplashDef, NormalSplashSound)} },
{ GEN_Class, {myoffsetof(FSplashDef, SmallSplash)} },
{ GEN_Class, {myoffsetof(FSplashDef, SplashBase)} },
{ GEN_Class, {myoffsetof(FSplashDef, SplashChunk)} },
{ GEN_Byte, {myoffsetof(FSplashDef, ChunkXVelShift)} },
{ GEN_Byte, {myoffsetof(FSplashDef, ChunkYVelShift)} },
{ GEN_Byte, {myoffsetof(FSplashDef, ChunkZVelShift)} },
{ GEN_Fixed, {myoffsetof(FSplashDef, ChunkBaseZVel)} },
{ GEN_Bool, {myoffsetof(FSplashDef, NoAlert)} }
{ GEN_Sound, {theoffsetof(FSplashDef, SmallSplashSound)} },
{ GEN_Fixed, {theoffsetof(FSplashDef, SmallSplashClip)} },
{ GEN_Sound, {theoffsetof(FSplashDef, NormalSplashSound)} },
{ GEN_Class, {theoffsetof(FSplashDef, SmallSplash)} },
{ GEN_Class, {theoffsetof(FSplashDef, SplashBase)} },
{ GEN_Class, {theoffsetof(FSplashDef, SplashChunk)} },
{ GEN_Byte, {theoffsetof(FSplashDef, ChunkXVelShift)} },
{ GEN_Byte, {theoffsetof(FSplashDef, ChunkYVelShift)} },
{ GEN_Byte, {theoffsetof(FSplashDef, ChunkZVelShift)} },
{ GEN_Fixed, {theoffsetof(FSplashDef, ChunkBaseZVel)} },
{ GEN_Bool, {theoffsetof(FSplashDef, NoAlert)} }
};
static FGenericParse TerrainParser[] =
{
{ GEN_End, {0} },
{ GEN_Splash, {myoffsetof(FTerrainDef, Splash)} },
{ GEN_Int, {myoffsetof(FTerrainDef, DamageAmount)} },
{ GEN_Splash, {theoffsetof(FTerrainDef, Splash)} },
{ GEN_Int, {theoffsetof(FTerrainDef, DamageAmount)} },
{ GEN_Custom, {(size_t)ParseDamage} },
{ GEN_Int, {myoffsetof(FTerrainDef, DamageTimeMask)} },
{ GEN_Fixed, {myoffsetof(FTerrainDef, FootClip)} },
{ GEN_Float, {myoffsetof(FTerrainDef, StepVolume)} },
{ GEN_Time, {myoffsetof(FTerrainDef, WalkStepTics)} },
{ GEN_Time, {myoffsetof(FTerrainDef, RunStepTics)} },
{ GEN_Sound, {myoffsetof(FTerrainDef, LeftStepSound)} },
{ GEN_Sound, {myoffsetof(FTerrainDef, RightStepSound)} },
{ GEN_Bool, {myoffsetof(FTerrainDef, IsLiquid)} },
{ GEN_Int, {theoffsetof(FTerrainDef, DamageTimeMask)} },
{ GEN_Fixed, {theoffsetof(FTerrainDef, FootClip)} },
{ GEN_Float, {theoffsetof(FTerrainDef, StepVolume)} },
{ GEN_Time, {theoffsetof(FTerrainDef, WalkStepTics)} },
{ GEN_Time, {theoffsetof(FTerrainDef, RunStepTics)} },
{ GEN_Sound, {theoffsetof(FTerrainDef, LeftStepSound)} },
{ GEN_Sound, {theoffsetof(FTerrainDef, RightStepSound)} },
{ GEN_Bool, {theoffsetof(FTerrainDef, IsLiquid)} },
{ GEN_Custom, {(size_t)ParseFriction} }
};

View file

@ -2793,7 +2793,7 @@ void R_InitBuildTiles ()
break;
}
int len = Q_filelength (f);
size_t len = Q_filelength (f);
BYTE *art = new BYTE[len];
if (fread (art, 1, len, f) != len || LittleLong(*(DWORD *)art) != 1)
{

View file

@ -1744,6 +1744,11 @@ do_stop:
case 'y':
v = ParseExpression (true);
break;
default:
assert(false);
v = -1;
break;
}
StateParameters[paramindex++]=v;
params++;

View file

@ -1084,7 +1084,7 @@ void A_SpawnItem(AActor * self)
if (index<0) return;
const PClass * missile= PClass::FindClass((ENamedName)StateParameters[index]);
fixed_t distance = EvalExpressionF (StateParameters[index+1], self);
fixed_t distance = fixed_t(EvalExpressionF (StateParameters[index+1], self) * FRACUNIT);
fixed_t zheight = fixed_t(EvalExpressionF (StateParameters[index+2], self) * FRACUNIT);
bool useammo = EvalExpressionN (StateParameters[index+3], self);
@ -1481,8 +1481,8 @@ void A_SetBlend(AActor * self)
int tics = EvalExpressionI (StateParameters[index+2], self);
PalEntry color2 = StateParameters[index+3];
if (color==-1) color=0;
if (color2==-1) color2=0;
if (color == MAKEARGB(255,255,255,255)) color=0;
if (color2 == MAKEARGB(255,255,255,255)) color2=0;
if (!color2.a)
color2 = color;

View file

@ -37,8 +37,8 @@
#include "doomtype.h"
#include "r_main.h"
#define MAKERGB(r,g,b) (((r)<<16)|((g)<<8)|(b))
#define MAKEARGB(a,r,g,b) (((a)<<24)|((r)<<16)|((g)<<8)|(b))
#define MAKERGB(r,g,b) DWORD(((r)<<16)|((g)<<8)|(b))
#define MAKEARGB(a,r,g,b) DWORD(((a)<<24)|((r)<<16)|((g)<<8)|(b))
#define APART(c) (((c)>>24)&0xff)
#define RPART(c) (((c)>>16)&0xff)

View file

@ -3,11 +3,13 @@ ifeq (Windows_NT,$(OS))
CCDV = @../../ccdv
CFLAGS = -Os -Wall -fomit-frame-pointer
LDFLAGS = -L../../zlib/ -lz
ZLIB = ../../zlib/libz.a
else
EXE = makewad
CCDV =
CFLAGS = -Dstricmp=strcasecmp -Dstrnicmp=strncasecmp -Os -Wall -fomit-frame-pointer
LDFLAGS = -lz
ZLIB =
endif
CC = gcc
@ -19,8 +21,13 @@ all: $(EXE)
.c.o:
$(CCDV) $(CC) $(CFLAGS) -c -o $@ $<
$(EXE): $(OBJS)
$(CCDV) $(CC) $(LDFLAGS) -o $(EXE) $(OBJS)
$(EXE): $(OBJS) $(ZLIB)
$(CCDV) $(CC) -o $(EXE) $(OBJS) $(LDFLAGS)
ifeq (Windows_NT,$(OS))
$(ZLIB):
make -C ../../zlib -f Makefile.mgw
endif
.PHONY: clean

View file

@ -107,7 +107,6 @@ int appendtozip (zipFile zipfile, const char * zipname, const char *filename)
char *readbuf;
FILE *lumpfile;
size_t readlen;
int ret = 0;
size_t len;
zip_fileinfo zip_inf;
@ -451,10 +450,6 @@ int buildwad (FILE *listfile, char *listfilename, char *makecmd, char *makefile)
return ret;
}
#if !defined(_MSC_VER)
#define __cdecl
#endif
int __cdecl main (int argc, char **argv)
{
FILE *listfile = NULL;

View file

@ -189,14 +189,14 @@ local void init_linkedlist(ll)
{
ll->first_block = ll->last_block = NULL;
}
/*
local void free_linkedlist(ll)
linkedlist_data* ll;
{
free_datablock(ll->first_block);
ll->first_block = ll->last_block = NULL;
}
*/
local int add_data_in_datablock(ll,buf,len)
linkedlist_data* ll;

View file

@ -13,10 +13,10 @@ clean:
del /q /f wadmake zdoom.pk3 xlat\*.x dehsupp.lmp 2>nul
../tools/makewad/makewad.exe:
$(MAKE) -C ../tools/makewad -f Makefile.mgw
$(MAKE) -C ../tools/makewad -f Makefile
../tools/xlatcc/xlatcc.exe:
$(MAKE) -C ../tools/xlatcc -f Makefile.mgw
$(MAKE) -C ../tools/xlatcc -f Makefile
../tools/dehsupp/dehsupp.exe:
$(MAKE) -C ../tools/dehsupp -f Makefile.mgw
$(MAKE) -C ../tools/dehsupp -f Makefile