- Fixed: SNDINFO must be loaded before the textures. However, this required

some changes to the MAPINFO parser which tried to access the texture manager
  to check if the level name patches exist. That check had to be moved to
  where the intermission screen is set up.
- Fixed: 'bloodcolor' ignored the first parameter value when given a list
  of integers.
  Please note that this creates an incompatibility between old and new 
  versions so if you want to create something that works with both 2.2.0
  and current versions better use the string format version for the color
  parameter!
- Rewrote the DECORATE property parser so that the parser is completely
  separated from the property handlers. This should allow reuse of all 
  the handler code for a new format if Doomscript requires one.
- Fixed: PClass::InitializeActorInfo copied too many bytes if a subclass's
  defaults were larger than the parent's.
- Moved A_ChangeFlag to thingdef_codeptr.cpp.
- Moved translation related code from thingdef_properties.cpp to r_translate.cpp
  and rewrote the translation parser to use FScanner instead of strtol.
- replaced DECORATE's 'alpha default' by 'defaultalpha' for consistency.
  Since this was never used outside zdoom.pk3 it's not critical.
- Removed support for game specific pickup messages because the only thing
  this was ever used for - Raven's invulnerability item - has already been
  split up into a Heretic and Hexen version.

SVN r1240 (trunk)
This commit is contained in:
Christoph Oelckers 2008-09-21 18:02:38 +00:00
commit 6227906072
38 changed files with 2123 additions and 2129 deletions

View file

@ -43,6 +43,9 @@
#include "colormatcher.h"
#include "d_netinf.h"
#include "v_palette.h"
#include "sc_man.h"
#include "doomerrors.h"
#include "i_system.h"
#include "gi.h"
#include "stats.h"
@ -82,11 +85,23 @@ FRemapTable::FRemapTable(int count)
// the caller will do that next, if only by calling MakeIdentity().
}
//----------------------------------------------------------------------------
//
//
//
//----------------------------------------------------------------------------
FRemapTable::~FRemapTable()
{
Free();
}
//----------------------------------------------------------------------------
//
//
//
//----------------------------------------------------------------------------
void FRemapTable::Alloc(int count)
{
Remap = (BYTE *)M_Malloc(count*sizeof(*Remap) + count*sizeof(*Palette));
@ -96,6 +111,12 @@ void FRemapTable::Alloc(int count)
NumEntries = count;
}
//----------------------------------------------------------------------------
//
//
//
//----------------------------------------------------------------------------
void FRemapTable::Free()
{
KillNative();
@ -108,6 +129,12 @@ void FRemapTable::Free()
}
}
//----------------------------------------------------------------------------
//
//
//
//----------------------------------------------------------------------------
FRemapTable::FRemapTable(const FRemapTable &o)
{
Remap = NULL;
@ -116,6 +143,12 @@ FRemapTable::FRemapTable(const FRemapTable &o)
operator= (o);
}
//----------------------------------------------------------------------------
//
//
//
//----------------------------------------------------------------------------
FRemapTable &FRemapTable::operator=(const FRemapTable &o)
{
if (&o == this)
@ -134,6 +167,12 @@ FRemapTable &FRemapTable::operator=(const FRemapTable &o)
return *this;
}
//----------------------------------------------------------------------------
//
//
//
//----------------------------------------------------------------------------
bool FRemapTable::operator==(const FRemapTable &o)
{
// Two translations are identical when they have the same amount of colors
@ -143,6 +182,12 @@ bool FRemapTable::operator==(const FRemapTable &o)
return !memcmp(o.Palette, Palette, NumEntries * sizeof(*Palette));
}
//----------------------------------------------------------------------------
//
//
//
//----------------------------------------------------------------------------
void FRemapTable::Serialize(FArchive &arc)
{
int n = NumEntries;
@ -167,6 +212,11 @@ void FRemapTable::Serialize(FArchive &arc)
}
}
//----------------------------------------------------------------------------
//
//
//
//----------------------------------------------------------------------------
void FRemapTable::MakeIdentity()
{
@ -186,6 +236,12 @@ void FRemapTable::MakeIdentity()
}
}
//----------------------------------------------------------------------------
//
//
//
//----------------------------------------------------------------------------
bool FRemapTable::IsIdentity() const
{
for (int j = 0; j < 256; ++j)
@ -198,6 +254,12 @@ bool FRemapTable::IsIdentity() const
return true;
}
//----------------------------------------------------------------------------
//
//
//
//----------------------------------------------------------------------------
void FRemapTable::KillNative()
{
if (Native != NULL)
@ -207,6 +269,12 @@ void FRemapTable::KillNative()
}
}
//----------------------------------------------------------------------------
//
//
//
//----------------------------------------------------------------------------
void FRemapTable::UpdateNative()
{
if (Native != NULL)
@ -215,6 +283,12 @@ void FRemapTable::UpdateNative()
}
}
//----------------------------------------------------------------------------
//
//
//
//----------------------------------------------------------------------------
FNativePalette *FRemapTable::GetNative()
{
if (Native == NULL)
@ -224,6 +298,12 @@ FNativePalette *FRemapTable::GetNative()
return Native;
}
//----------------------------------------------------------------------------
//
//
//
//----------------------------------------------------------------------------
void FRemapTable::AddIndexRange(int start, int end, int pal1, int pal2)
{
fixed_t palcol, palstep;
@ -250,6 +330,12 @@ void FRemapTable::AddIndexRange(int start, int end, int pal1, int pal2)
}
}
//----------------------------------------------------------------------------
//
//
//
//----------------------------------------------------------------------------
void FRemapTable::AddColorRange(int start, int end, int _r1,int _g1, int _b1, int _r2, int _g2, int _b2)
{
fixed_t r1 = _r1 << FRACBITS;
@ -304,6 +390,160 @@ void FRemapTable::AddColorRange(int start, int end, int _r1,int _g1, int _b1, in
}
}
//----------------------------------------------------------------------------
//
//
//
//----------------------------------------------------------------------------
void FRemapTable::AddToTranslation(const char * range)
{
int start,end;
FScanner sc;
sc.OpenMem("translation", range, int(strlen(range)));
sc.SetCMode(true);
try
{
sc.MustGetToken(TK_IntConst);
start = sc.Number;
sc.MustGetToken(':');
sc.MustGetToken(TK_IntConst);
end = sc.Number;
sc.MustGetToken('=');
if (!sc.CheckToken('['))
{
int pal1,pal2;
sc.MustGetToken(TK_IntConst);
pal1 = sc.Number;
sc.MustGetToken(':');
sc.MustGetToken(TK_IntConst);
pal2 = sc.Number;
AddIndexRange(start, end, pal1, pal2);
}
else
{
// translation using RGB values
int r1,g1,b1,r2,g2,b2;
sc.MustGetToken(TK_IntConst);
r1 = sc.Number;
sc.MustGetToken(',');
sc.MustGetToken(TK_IntConst);
g1 = sc.Number;
sc.MustGetToken(',');
sc.MustGetToken(TK_IntConst);
b1 = sc.Number;
sc.MustGetToken(']');
sc.MustGetToken(':');
sc.MustGetToken('[');
sc.MustGetToken(TK_IntConst);
r2 = sc.Number;
sc.MustGetToken(',');
sc.MustGetToken(TK_IntConst);
g2 = sc.Number;
sc.MustGetToken(',');
sc.MustGetToken(TK_IntConst);
b2 = sc.Number;
sc.MustGetToken(']');
AddColorRange(start, end, r1, g1, b1, r2, g2, b2);
}
}
catch (CRecoverableError &err)
{
Printf("Error in translation '%s':\n%s\n", err.GetMessage());
}
}
//----------------------------------------------------------------------------
//
// Stores a copy of this translation in the DECORATE translation table
//
//----------------------------------------------------------------------------
int FRemapTable::StoreTranslation()
{
unsigned int i;
for (i = 0; i < translationtables[TRANSLATION_Decorate].Size(); i++)
{
if (*this == *translationtables[TRANSLATION_Decorate][i])
{
// A duplicate of this translation already exists
return TRANSLATION(TRANSLATION_Decorate, i);
}
}
if (translationtables[TRANSLATION_Decorate].Size() >= MAX_DECORATE_TRANSLATIONS)
{
I_Error("Too many DECORATE translations");
}
FRemapTable *newtrans = new FRemapTable;
*newtrans = *this;
i = translationtables[TRANSLATION_Decorate].Push(newtrans);
return TRANSLATION(TRANSLATION_Decorate, i);
}
//----------------------------------------------------------------------------
//
//
//
//----------------------------------------------------------------------------
TArray<PalEntry> BloodTranslationColors;
int CreateBloodTranslation(PalEntry color)
{
unsigned int i;
if (BloodTranslationColors.Size() == 0)
{
// Don't use the first slot.
translationtables[TRANSLATION_Blood].Push(NULL);
BloodTranslationColors.Push(0);
}
for (i = 1; i < BloodTranslationColors.Size(); i++)
{
if (color.r == BloodTranslationColors[i].r &&
color.g == BloodTranslationColors[i].g &&
color.b == BloodTranslationColors[i].b)
{
// A duplicate of this translation already exists
return i;
}
}
if (BloodTranslationColors.Size() >= MAX_DECORATE_TRANSLATIONS)
{
I_Error("Too many blood colors");
}
FRemapTable *trans = new FRemapTable;
for (i = 0; i < 256; i++)
{
int bright = MAX(MAX(GPalette.BaseColors[i].r, GPalette.BaseColors[i].g), GPalette.BaseColors[i].b);
PalEntry pe = PalEntry(color.r*bright/255, color.g*bright/255, color.b*bright/255);
int entry = ColorMatcher.Pick(pe.r, pe.g, pe.b);
trans->Palette[i] = pe;
trans->Remap[i] = entry;
}
translationtables[TRANSLATION_Blood].Push(trans);
return BloodTranslationColors.Push(color);
}
//----------------------------------------------------------------------------
//
//
//
//----------------------------------------------------------------------------
FRemapTable *TranslationToTable(int translation)
{
@ -323,6 +563,12 @@ FRemapTable *TranslationToTable(int translation)
return slots->operator[](index);
}
//----------------------------------------------------------------------------
//
//
//
//----------------------------------------------------------------------------
static void PushIdentityTable(int slot)
{
FRemapTable *table = new FRemapTable;
@ -330,11 +576,14 @@ static void PushIdentityTable(int slot)
translationtables[slot].Push(table);
}
//----------------------------------------------------------------------------
//
// R_InitTranslationTables
// Creates the translation tables to map the green color ramp to gray,
// brown, red. Assumes a given structure of the PLAYPAL.
//
//----------------------------------------------------------------------------
void R_InitTranslationTables ()
{
int i, j;
@ -508,6 +757,12 @@ void R_InitTranslationTables ()
}
}
//----------------------------------------------------------------------------
//
//
//
//----------------------------------------------------------------------------
void R_DeinitTranslationTables()
{
for (int i = 0; i < NUM_TRANSLATION_TABLES; ++i)
@ -523,8 +778,13 @@ void R_DeinitTranslationTables()
}
}
//----------------------------------------------------------------------------
//
// [RH] Create a player's translation table based on a given mid-range color.
// [GRB] Split to 2 functions (because of player setup menu)
//
//----------------------------------------------------------------------------
static void SetRemap(FRemapTable *table, int i, float r, float g, float b)
{
int ir = clamp (int(r * 255.f), 0, 255);
@ -534,6 +794,12 @@ static void SetRemap(FRemapTable *table, int i, float r, float g, float b)
table->Palette[i] = PalEntry(255, ir, ig, ib);
}
//----------------------------------------------------------------------------
//
//
//
//----------------------------------------------------------------------------
static void R_CreatePlayerTranslation (float h, float s, float v, FPlayerSkin *skin, FRemapTable *table, FRemapTable *alttable)
{
int i;
@ -675,6 +941,12 @@ static void R_CreatePlayerTranslation (float h, float s, float v, FPlayerSkin *s
table->UpdateNative();
}
//----------------------------------------------------------------------------
//
//
//
//----------------------------------------------------------------------------
void R_BuildPlayerTranslation (int player)
{
float h, s, v;
@ -687,6 +959,12 @@ void R_BuildPlayerTranslation (int player)
translationtables[TRANSLATION_PlayersExtra][player]);
}
//----------------------------------------------------------------------------
//
//
//
//----------------------------------------------------------------------------
void R_GetPlayerTranslation (int color, FPlayerSkin *skin, FRemapTable *table)
{
float h, s, v;
@ -696,3 +974,4 @@ void R_GetPlayerTranslation (int color, FPlayerSkin *skin, FRemapTable *table)
R_CreatePlayerTranslation (h, s, v, skin, table, NULL);
}