1
0
Fork 0

Shortened enums

This commit is contained in:
andrew 2014-03-01 14:20:29 +02:00
parent a28e5eca18
commit 692a84af31
4 changed files with 58 additions and 58 deletions

View File

@ -859,7 +859,7 @@ void cPlayer::KilledBy(cEntity * a_Killer)
{ {
GetWorld()->BroadcastChatDeath(Printf("%s was killed by %s", GetName().c_str(), ((cPlayer *)a_Killer)->GetName().c_str())); GetWorld()->BroadcastChatDeath(Printf("%s was killed by %s", GetName().c_str(), ((cPlayer *)a_Killer)->GetName().c_str()));
m_World->GetScoreBoard().AddPlayerScore(((cPlayer *)a_Killer)->GetName(), cObjective::E_TYPE_PLAYER_KILL_COUNT, 1); m_World->GetScoreBoard().AddPlayerScore(((cPlayer *)a_Killer)->GetName(), cObjective::otPlayerKillCount, 1);
} }
else else
{ {
@ -869,7 +869,7 @@ void cPlayer::KilledBy(cEntity * a_Killer)
GetWorld()->BroadcastChatDeath(Printf("%s was killed by a %s", GetName().c_str(), KillerClass.c_str())); GetWorld()->BroadcastChatDeath(Printf("%s was killed by a %s", GetName().c_str(), KillerClass.c_str()));
} }
m_World->GetScoreBoard().AddPlayerScore(GetName(), cObjective::E_TYPE_DEATH_COUNT, 1); m_World->GetScoreBoard().AddPlayerScore(GetName(), cObjective::otDeathCount, 1);
} }

View File

@ -17,19 +17,19 @@ AString cObjective::TypeToString(eType a_Type)
{ {
switch (a_Type) switch (a_Type)
{ {
case E_TYPE_DUMMY: return "dummy"; case otDummy: return "dummy";
case E_TYPE_DEATH_COUNT: return "deathCount"; case otDeathCount: return "deathCount";
case E_TYPE_PLAYER_KILL_COUNT: return "playerKillCount"; case otPlayerKillCount: return "playerKillCount";
case E_TYPE_TOTAL_KILL_COUNT: return "totalKillCount"; case otTotalKillCount: return "totalKillCount";
case E_TYPE_HEALTH: return "health"; case otHealth: return "health";
case E_TYPE_ACHIEVEMENT: return "achievement"; case otAchievement: return "achievement";
case E_TYPE_STAT: return "stat"; case otStat: return "stat";
case E_TYPE_STAT_ITEM_CRAFT: return "stat.craftItem"; case otStatItemCraft: return "stat.craftItem";
case E_TYPE_STAT_ITEM_USE: return "stat.useItem"; case otStatItemUse: return "stat.useItem";
case E_TYPE_STAT_ITEM_BREAK: return "stat.breakItem"; case otStatItemBreak: return "stat.breakItem";
case E_TYPE_STAT_BLOCK_MINE: return "stat.mineBlock"; case otStatBlockMine: return "stat.mineBlock";
case E_TYPE_STAT_ENTITY_KILL: return "stat.killEntity"; case otStatEntityKill: return "stat.killEntity";
case E_TYPE_STAT_ENTITY_KILLED_BY: return "stat.entityKilledBy"; case otStatEntityKilledBy: return "stat.entityKilledBy";
default: return ""; default: return "";
} }
@ -46,19 +46,19 @@ cObjective::eType cObjective::StringToType(const AString & a_Name)
const char * m_String; const char * m_String;
} TypeMap [] = } TypeMap [] =
{ {
{E_TYPE_DUMMY, "dummy"}, {otDummy, "dummy" },
{E_TYPE_DEATH_COUNT, "deathCount"}, {otDeathCount, "deathCount" },
{E_TYPE_PLAYER_KILL_COUNT, "playerKillCount"}, {otPlayerKillCount, "playerKillCount" },
{E_TYPE_TOTAL_KILL_COUNT, "totalKillCount"}, {otTotalKillCount, "totalKillCount" },
{E_TYPE_HEALTH, "health"}, {otHealth, "health" },
{E_TYPE_ACHIEVEMENT, "achievement"}, {otAchievement, "achievement" },
{E_TYPE_STAT, "stat"}, {otStat, "stat" },
{E_TYPE_STAT_ITEM_CRAFT, "stat.craftItem"}, {otStatItemCraft, "stat.craftItem" },
{E_TYPE_STAT_ITEM_USE, "stat.useItem"}, {otStatItemUse, "stat.useItem" },
{E_TYPE_STAT_ITEM_BREAK, "stat.breakItem"}, {otStatItemBreak, "stat.breakItem" },
{E_TYPE_STAT_BLOCK_MINE, "stat.mineBlock"}, {otStatBlockMine, "stat.mineBlock" },
{E_TYPE_STAT_ENTITY_KILL, "stat.killEntity"}, {otStatEntityKill, "stat.killEntity" },
{E_TYPE_STAT_ENTITY_KILLED_BY, "stat.entityKilledBy"} {otStatEntityKilledBy, "stat.entityKilledBy"}
}; };
for (size_t i = 0; i < ARRAYCOUNT(TypeMap); i++) for (size_t i = 0; i < ARRAYCOUNT(TypeMap); i++)
{ {
@ -67,7 +67,7 @@ cObjective::eType cObjective::StringToType(const AString & a_Name)
return TypeMap[i].m_Type; return TypeMap[i].m_Type;
} }
} // for i - TypeMap[] } // for i - TypeMap[]
return E_TYPE_DUMMY; return otDummy;
} }
@ -268,7 +268,7 @@ unsigned int cTeam::GetNumPlayers(void) const
cScoreboard::cScoreboard(cWorld * a_World) : m_World(a_World) cScoreboard::cScoreboard(cWorld * a_World) : m_World(a_World)
{ {
for (int i = 0; i < (int) E_DISPLAY_SLOT_COUNT; ++i) for (int i = 0; i < (int) dsCount; ++i)
{ {
m_Display[i] = NULL; m_Display[i] = NULL;
} }
@ -423,7 +423,7 @@ cTeam * cScoreboard::QueryPlayerTeam(const AString & a_Name)
void cScoreboard::SetDisplay(const AString & a_Objective, eDisplaySlot a_Slot) void cScoreboard::SetDisplay(const AString & a_Objective, eDisplaySlot a_Slot)
{ {
ASSERT(a_Slot < E_DISPLAY_SLOT_COUNT); ASSERT(a_Slot < dsCount);
cObjective * Objective = GetObjective(a_Objective); cObjective * Objective = GetObjective(a_Objective);
@ -448,7 +448,7 @@ void cScoreboard::SetDisplay(cObjective * a_Objective, eDisplaySlot a_Slot)
cObjective * cScoreboard::GetObjectiveIn(eDisplaySlot a_Slot) cObjective * cScoreboard::GetObjectiveIn(eDisplaySlot a_Slot)
{ {
ASSERT(a_Slot < E_DISPLAY_SLOT_COUNT); ASSERT(a_Slot < dsCount);
return m_Display[a_Slot]; return m_Display[a_Slot];
} }
@ -524,7 +524,7 @@ void cScoreboard::SendTo(cClientHandle & a_Client)
it->second.SendTo(a_Client); it->second.SendTo(a_Client);
} }
for (int i = 0; i < (int) E_DISPLAY_SLOT_COUNT; ++i) for (int i = 0; i < (int) dsCount; ++i)
{ {
// Avoid race conditions // Avoid race conditions
cObjective * Objective = m_Display[i]; cObjective * Objective = m_Display[i];

View File

@ -31,23 +31,23 @@ public:
enum eType enum eType
{ {
E_TYPE_DUMMY, otDummy,
E_TYPE_DEATH_COUNT, otDeathCount,
E_TYPE_PLAYER_KILL_COUNT, otPlayerKillCount,
E_TYPE_TOTAL_KILL_COUNT, otTotalKillCount,
E_TYPE_HEALTH, otHealth,
E_TYPE_ACHIEVEMENT, otAchievement,
E_TYPE_STAT, otStat,
E_TYPE_STAT_ITEM_CRAFT, otStatItemCraft,
E_TYPE_STAT_ITEM_USE, otStatItemUse,
E_TYPE_STAT_ITEM_BREAK, otStatItemBreak,
E_TYPE_STAT_BLOCK_MINE, otStatBlockMine,
E_TYPE_STAT_ENTITY_KILL, otStatEntityKill,
E_TYPE_STAT_ENTITY_KILLED_BY otStatEntityKilledBy
}; };
// tolua_end // tolua_end
@ -201,11 +201,11 @@ public:
enum eDisplaySlot enum eDisplaySlot
{ {
E_DISPLAY_SLOT_LIST = 0, dsList = 0,
E_DISPLAY_SLOT_SIDEBAR, dsSidebar,
E_DISPLAY_SLOT_NAME, dsName,
E_DISPLAY_SLOT_COUNT dsCount
}; };
// tolua_end // tolua_end
@ -284,7 +284,7 @@ private:
cWorld * m_World; cWorld * m_World;
cObjective* m_Display[E_DISPLAY_SLOT_COUNT]; cObjective * m_Display[dsCount];
friend class cScoreboardSerializer; friend class cScoreboardSerializer;

View File

@ -173,13 +173,13 @@ void cScoreboardSerializer::SaveScoreboardToNBT(cFastNBTWriter & a_Writer)
a_Writer.BeginCompound("DisplaySlots"); a_Writer.BeginCompound("DisplaySlots");
cObjective * Objective = m_ScoreBoard->GetObjectiveIn(cScoreboard::E_DISPLAY_SLOT_LIST); cObjective * Objective = m_ScoreBoard->GetObjectiveIn(cScoreboard::dsList);
a_Writer.AddString("slot_0", (Objective == NULL) ? "" : Objective->GetName()); a_Writer.AddString("slot_0", (Objective == NULL) ? "" : Objective->GetName());
Objective = m_ScoreBoard->GetObjectiveIn(cScoreboard::E_DISPLAY_SLOT_SIDEBAR); Objective = m_ScoreBoard->GetObjectiveIn(cScoreboard::dsSidebar);
a_Writer.AddString("slot_1", (Objective == NULL) ? "" : Objective->GetName()); a_Writer.AddString("slot_1", (Objective == NULL) ? "" : Objective->GetName());
Objective = m_ScoreBoard->GetObjectiveIn(cScoreboard::E_DISPLAY_SLOT_NAME); Objective = m_ScoreBoard->GetObjectiveIn(cScoreboard::dsName);
a_Writer.AddString("slot_2", (Objective == NULL) ? "" : Objective->GetName()); a_Writer.AddString("slot_2", (Objective == NULL) ? "" : Objective->GetName());
a_Writer.EndCompound(); // DisplaySlots a_Writer.EndCompound(); // DisplaySlots
@ -280,7 +280,7 @@ bool cScoreboardSerializer::LoadScoreboardFromNBT(const cParsedNBT & a_NBT)
{ {
AString Name, DisplayName, Prefix, Suffix; AString Name, DisplayName, Prefix, Suffix;
bool AllowsFriendlyFire = false, CanSeeFriendlyInvisible = false; bool AllowsFriendlyFire = true, CanSeeFriendlyInvisible = false;
int CurrLine = a_NBT.FindChildByName(Child, "Name"); int CurrLine = a_NBT.FindChildByName(Child, "Name");
if (CurrLine >= 0) if (CurrLine >= 0)
@ -346,7 +346,7 @@ bool cScoreboardSerializer::LoadScoreboardFromNBT(const cParsedNBT & a_NBT)
{ {
AString Name = a_NBT.GetString(CurrLine); AString Name = a_NBT.GetString(CurrLine);
m_ScoreBoard->SetDisplay(Name, cScoreboard::E_DISPLAY_SLOT_LIST); m_ScoreBoard->SetDisplay(Name, cScoreboard::dsList);
} }
CurrLine = a_NBT.FindChildByName(DisplaySlots, "slot_1"); CurrLine = a_NBT.FindChildByName(DisplaySlots, "slot_1");
@ -354,7 +354,7 @@ bool cScoreboardSerializer::LoadScoreboardFromNBT(const cParsedNBT & a_NBT)
{ {
AString Name = a_NBT.GetString(CurrLine); AString Name = a_NBT.GetString(CurrLine);
m_ScoreBoard->SetDisplay(Name, cScoreboard::E_DISPLAY_SLOT_SIDEBAR); m_ScoreBoard->SetDisplay(Name, cScoreboard::dsSidebar);
} }
CurrLine = a_NBT.FindChildByName(DisplaySlots, "slot_2"); CurrLine = a_NBT.FindChildByName(DisplaySlots, "slot_2");
@ -362,7 +362,7 @@ bool cScoreboardSerializer::LoadScoreboardFromNBT(const cParsedNBT & a_NBT)
{ {
AString Name = a_NBT.GetString(CurrLine); AString Name = a_NBT.GetString(CurrLine);
m_ScoreBoard->SetDisplay(Name, cScoreboard::E_DISPLAY_SLOT_NAME); m_ScoreBoard->SetDisplay(Name, cScoreboard::dsName);
} }
return true; return true;