- Applied latest TEAMINFO patch.
SVN r1400 (trunk)
This commit is contained in:
parent
403b2c3c56
commit
b387752f2f
10 changed files with 336 additions and 156 deletions
312
src/teaminfo.cpp
312
src/teaminfo.cpp
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
** teaminfo.cpp
|
||||
** Implementation of the TEAMINFO lump.
|
||||
** Parses TEAMINFO and manages teams.
|
||||
**
|
||||
**---------------------------------------------------------------------------
|
||||
** Copyright 2007-2008 Christopher Westley
|
||||
** Copyright 2007-2009 Christopher Westley
|
||||
** All rights reserved.
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
|
|
@ -34,12 +34,12 @@
|
|||
|
||||
// HEADER FILES ------------------------------------------------------------
|
||||
|
||||
#include "c_dispatch.h"
|
||||
#include "gi.h"
|
||||
#include "i_system.h"
|
||||
#include "sc_man.h"
|
||||
#include "teaminfo.h"
|
||||
#include "v_video.h"
|
||||
#include "v_palette.h"
|
||||
#include "v_font.h"
|
||||
#include "v_video.h"
|
||||
#include "w_wad.h"
|
||||
|
||||
// MACROS ------------------------------------------------------------------
|
||||
|
|
@ -50,136 +50,300 @@
|
|||
|
||||
// PUBLIC FUNCTION PROTOTYPES ----------------------------------------------
|
||||
|
||||
void TEAMINFO_Init ();
|
||||
void TEAMINFO_ParseTeam (FScanner &sc);
|
||||
|
||||
bool TEAMINFO_IsValidTeam (int team);
|
||||
|
||||
// PRIVATE FUNCTION PROTOTYPES ---------------------------------------------
|
||||
|
||||
// EXTERNAL DATA DECLARATIONS ----------------------------------------------
|
||||
|
||||
// PUBLIC DATA DEFINITIONS -------------------------------------------------
|
||||
|
||||
TArray <TEAMINFO> teams;
|
||||
FTeam TeamLibrary;
|
||||
TArray<FTeam> Teams;
|
||||
|
||||
// PRIVATE DATA DEFINITIONS ------------------------------------------------
|
||||
|
||||
static const char *keywords_teaminfo [] = {
|
||||
"PLAYERCOLOR",
|
||||
"TEXTCOLOR",
|
||||
"LOGO",
|
||||
NULL
|
||||
static const char *TeamInfoOptions[] =
|
||||
{
|
||||
"Game",
|
||||
"PlayerColor",
|
||||
"TextColor",
|
||||
"Logo",
|
||||
"AllowCustomPlayerColor",
|
||||
"RailColor",
|
||||
"FlagItem",
|
||||
"SkullItem",
|
||||
"PlayerStartThingNumber",
|
||||
"SmallFlagHUDIcon",
|
||||
"SmallSkullHUDIcon",
|
||||
"LargeFlagHUDIcon",
|
||||
"LargeSkullHUDIcon",
|
||||
"WinnerPic",
|
||||
"LoserPic",
|
||||
"WinnerTheme",
|
||||
"LoserTheme",
|
||||
};
|
||||
|
||||
enum ETeamOptions
|
||||
{
|
||||
TEAMINFO_Game,
|
||||
TEAMINFO_PlayerColor,
|
||||
TEAMINFO_TextColor,
|
||||
TEAMINFO_Logo,
|
||||
TEAMINFO_AllowCustomPlayerColor,
|
||||
TEAMINFO_RailColor,
|
||||
TEAMINFO_FlagItem,
|
||||
TEAMINFO_SkullItem,
|
||||
TEAMINFO_PlayerStartThingNumber,
|
||||
TEAMINFO_SmallFlagHUDIcon,
|
||||
TEAMINFO_SmallSkullHUDIcon,
|
||||
TEAMINFO_LargeFlagHUDIcon,
|
||||
TEAMINFO_LargeSkullHUDIcon,
|
||||
TEAMINFO_WinnerPic,
|
||||
TEAMINFO_LoserPic,
|
||||
TEAMINFO_WinnerTheme,
|
||||
TEAMINFO_LoserTheme,
|
||||
};
|
||||
|
||||
// CODE --------------------------------------------------------------------
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// TEAMINFO_Init
|
||||
// FTeam :: FTeam
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void TEAMINFO_Init ()
|
||||
FTeam::FTeam ()
|
||||
{
|
||||
int lastlump = 0, lump;
|
||||
|
||||
while ((lump = Wads.FindLump ("TEAMINFO", &lastlump)) != -1)
|
||||
{
|
||||
FScanner sc(lump);
|
||||
while (sc.GetString ())
|
||||
{
|
||||
if (sc.Compare("CLEARTEAMS"))
|
||||
teams.Clear ();
|
||||
else if (sc.Compare("TEAM"))
|
||||
TEAMINFO_ParseTeam (sc);
|
||||
else
|
||||
sc.ScriptError ("Unknown command %s in TEAMINFO", sc.String);
|
||||
}
|
||||
}
|
||||
|
||||
if (teams.Size () < 2)
|
||||
I_FatalError ("At least two teams must be defined in TEAMINFO");
|
||||
m_GameFilter = 0;
|
||||
m_iPlayerColor = 0;
|
||||
m_iPlayerCount = 0;
|
||||
m_iScore = 0;
|
||||
m_iPresent = 0;
|
||||
m_iTies = 0;
|
||||
m_bAllowCustomPlayerColor = false;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// TEAMINFO_ParseTeam
|
||||
// FTeam :: ParseTeamInfo
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void TEAMINFO_ParseTeam (FScanner &sc)
|
||||
void FTeam::ParseTeamInfo ()
|
||||
{
|
||||
TEAMINFO team;
|
||||
int i;
|
||||
int iLump, iLastLump = 0;
|
||||
|
||||
sc.MustGetString ();
|
||||
team.name = sc.String;
|
||||
|
||||
sc.MustGetStringName("{");
|
||||
while (!sc.CheckString("}"))
|
||||
while ((iLump = Wads.FindLump ("TEAMINFO", &iLastLump)) != -1)
|
||||
{
|
||||
sc.MustGetString();
|
||||
switch(i = sc.MatchString (keywords_teaminfo))
|
||||
FScanner Scan (iLump);
|
||||
|
||||
while (Scan.GetString ())
|
||||
{
|
||||
case 0:
|
||||
sc.MustGetString ();
|
||||
team.playercolor = V_GetColor (NULL, sc.String);
|
||||
if (Scan.Compare ("ClearTeams"))
|
||||
ClearTeams ();
|
||||
else if (Scan.Compare ("Team"))
|
||||
ParseTeamDefinition (Scan);
|
||||
else
|
||||
Scan.ScriptError ("ParseTeamInfo: Unknown team command '%s'.\n", Scan.String);
|
||||
}
|
||||
}
|
||||
|
||||
if (Teams.Size () < 2)
|
||||
I_FatalError ("ParseTeamInfo: At least two teams must be defined in TEAMINFO.");
|
||||
else if (Teams.Size () > TEAM_MAXIMUM)
|
||||
I_FatalError ("ParseTeamInfo: Too many teams defined. (Maximum: %d)", TEAM_MAXIMUM);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// FTeam :: ParseTeamDefinition
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void FTeam::ParseTeamDefinition (FScanner &Scan)
|
||||
{
|
||||
FTeam Team;
|
||||
Scan.MustGetString ();
|
||||
Team.m_Name = Scan.String;
|
||||
Scan.MustGetStringName ("{");
|
||||
|
||||
while (!Scan.CheckString ("}"))
|
||||
{
|
||||
Scan.MustGetString ();
|
||||
|
||||
switch (Scan.MatchString (TeamInfoOptions))
|
||||
{
|
||||
case TEAMINFO_Game:
|
||||
Scan.MustGetString ();
|
||||
|
||||
if (!stricmp (Scan.String, "Doom"))
|
||||
Team.m_GameFilter |= GAME_Doom;
|
||||
else if (!stricmp (Scan.String, "Heretic"))
|
||||
Team.m_GameFilter |= GAME_Heretic;
|
||||
else if (!stricmp (Scan.String, "Hexen"))
|
||||
Team.m_GameFilter |= GAME_Hexen;
|
||||
else if (!stricmp (Scan.String, "Raven"))
|
||||
Team.m_GameFilter |= GAME_Raven;
|
||||
else if (!stricmp (Scan.String, "Strife"))
|
||||
Team.m_GameFilter |= GAME_Strife;
|
||||
else if (!stricmp (Scan.String, "Chex"))
|
||||
Team.m_GameFilter |= GAME_Chex;
|
||||
else if (!stricmp (Scan.String, "Any"))
|
||||
Team.m_GameFilter |= GAME_Any;
|
||||
else
|
||||
Scan.ScriptError ("ParseTeamDefinition: Unknown game type '%s'.\n", Scan.String);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
sc.MustGetString();
|
||||
team.textcolor = '[';
|
||||
team.textcolor << sc.String << ']';
|
||||
case TEAMINFO_PlayerColor:
|
||||
Scan.MustGetString ();
|
||||
Team.m_iPlayerColor = V_GetColor (NULL, Scan.String);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
sc.MustGetString ();
|
||||
team.logo = sc.String;
|
||||
case TEAMINFO_TextColor:
|
||||
Scan.MustGetString ();
|
||||
Team.m_TextColor.AppendFormat ("[%s]", Scan.String);
|
||||
break;
|
||||
|
||||
case TEAMINFO_Logo:
|
||||
Scan.MustGetString ();
|
||||
Team.m_Logo = Scan.String;
|
||||
break;
|
||||
|
||||
case TEAMINFO_AllowCustomPlayerColor:
|
||||
Team.m_bAllowCustomPlayerColor = true;
|
||||
break;
|
||||
|
||||
case TEAMINFO_PlayerStartThingNumber:
|
||||
Scan.MustGetNumber ();
|
||||
break;
|
||||
|
||||
case TEAMINFO_RailColor:
|
||||
case TEAMINFO_FlagItem:
|
||||
case TEAMINFO_SkullItem:
|
||||
case TEAMINFO_SmallFlagHUDIcon:
|
||||
case TEAMINFO_SmallSkullHUDIcon:
|
||||
case TEAMINFO_LargeFlagHUDIcon:
|
||||
case TEAMINFO_LargeSkullHUDIcon:
|
||||
case TEAMINFO_WinnerPic:
|
||||
case TEAMINFO_LoserPic:
|
||||
case TEAMINFO_WinnerTheme:
|
||||
case TEAMINFO_LoserTheme:
|
||||
Scan.MustGetString ();
|
||||
break;
|
||||
|
||||
default:
|
||||
Scan.ScriptError ("ParseTeamDefinition: Unknown team option '%s'.\n", Scan.String);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
teams.Push (team);
|
||||
if (Team.m_GameFilter == 0 || Team.m_GameFilter & gameinfo.gametype)
|
||||
Teams.Push (Team);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// TEAMINFO_IsValidTeam
|
||||
// FTeam :: ClearTeams
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
bool TEAMINFO_IsValidTeam (int team)
|
||||
void FTeam::ClearTeams ()
|
||||
{
|
||||
if (team < 0 || team >= (signed)teams.Size ())
|
||||
{
|
||||
Teams.Clear ();
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// FTeam :: IsValidTeam
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
bool FTeam::IsValidTeam (unsigned int uiTeam)
|
||||
{
|
||||
if (uiTeam < 0 || uiTeam >= Teams.Size ())
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// TEAMINFO :: GetTextColor
|
||||
// FTeam :: GetName
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
int TEAMINFO::GetTextColor () const
|
||||
const char *FTeam::GetName () const
|
||||
{
|
||||
if (textcolor.IsEmpty())
|
||||
return m_Name;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// FTeam :: GetPlayerColor
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
int FTeam::GetPlayerColor () const
|
||||
{
|
||||
return m_iPlayerColor;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// FTeam :: GetTextColor
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
int FTeam::GetTextColor () const
|
||||
{
|
||||
if (m_TextColor.IsEmpty ())
|
||||
return CR_UNTRANSLATED;
|
||||
|
||||
const BYTE *pColor = (const BYTE *)m_TextColor.GetChars ();
|
||||
int iColor = V_ParseFontColor (pColor, 0, 0);
|
||||
|
||||
if (iColor == CR_UNDEFINED)
|
||||
{
|
||||
Printf ("GetTextColor: Undefined color '%s' in definition of team '%s'.\n", m_TextColor.GetChars (), m_Name.GetChars ());
|
||||
return CR_UNTRANSLATED;
|
||||
}
|
||||
const BYTE *cp = (const BYTE *)textcolor.GetChars();
|
||||
int color = V_ParseFontColor(cp, 0, 0);
|
||||
if (color == CR_UNDEFINED)
|
||||
{
|
||||
Printf("Undefined color '%s' in definition of team %s\n", textcolor.GetChars (), name.GetChars ());
|
||||
color = CR_UNTRANSLATED;
|
||||
}
|
||||
return color;
|
||||
|
||||
return iColor;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// FTeam :: GetLogo
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
FString FTeam::GetLogo () const
|
||||
{
|
||||
return m_Logo;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// FTeam :: GetAllowCustomPlayerColor
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
bool FTeam::GetAllowCustomPlayerColor () const
|
||||
{
|
||||
return m_bAllowCustomPlayerColor;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// CCMD teamlist
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
CCMD (teamlist)
|
||||
{
|
||||
Printf ("Defined teams are as follows:\n");
|
||||
|
||||
for (unsigned int uiTeam = 0; uiTeam < Teams.Size (); uiTeam++)
|
||||
Printf ("%d : %s\n", uiTeam, Teams[uiTeam].GetName ());
|
||||
|
||||
Printf ("End of team list.\n");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue