Shortened enums
This commit is contained in:
parent
a28e5eca18
commit
692a84af31
@ -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()));
|
||||
|
||||
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
|
||||
{
|
||||
@ -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()));
|
||||
}
|
||||
|
||||
m_World->GetScoreBoard().AddPlayerScore(GetName(), cObjective::E_TYPE_DEATH_COUNT, 1);
|
||||
m_World->GetScoreBoard().AddPlayerScore(GetName(), cObjective::otDeathCount, 1);
|
||||
}
|
||||
|
||||
|
||||
|
@ -17,19 +17,19 @@ AString cObjective::TypeToString(eType a_Type)
|
||||
{
|
||||
switch (a_Type)
|
||||
{
|
||||
case E_TYPE_DUMMY: return "dummy";
|
||||
case E_TYPE_DEATH_COUNT: return "deathCount";
|
||||
case E_TYPE_PLAYER_KILL_COUNT: return "playerKillCount";
|
||||
case E_TYPE_TOTAL_KILL_COUNT: return "totalKillCount";
|
||||
case E_TYPE_HEALTH: return "health";
|
||||
case E_TYPE_ACHIEVEMENT: return "achievement";
|
||||
case E_TYPE_STAT: return "stat";
|
||||
case E_TYPE_STAT_ITEM_CRAFT: return "stat.craftItem";
|
||||
case E_TYPE_STAT_ITEM_USE: return "stat.useItem";
|
||||
case E_TYPE_STAT_ITEM_BREAK: return "stat.breakItem";
|
||||
case E_TYPE_STAT_BLOCK_MINE: return "stat.mineBlock";
|
||||
case E_TYPE_STAT_ENTITY_KILL: return "stat.killEntity";
|
||||
case E_TYPE_STAT_ENTITY_KILLED_BY: return "stat.entityKilledBy";
|
||||
case otDummy: return "dummy";
|
||||
case otDeathCount: return "deathCount";
|
||||
case otPlayerKillCount: return "playerKillCount";
|
||||
case otTotalKillCount: return "totalKillCount";
|
||||
case otHealth: return "health";
|
||||
case otAchievement: return "achievement";
|
||||
case otStat: return "stat";
|
||||
case otStatItemCraft: return "stat.craftItem";
|
||||
case otStatItemUse: return "stat.useItem";
|
||||
case otStatItemBreak: return "stat.breakItem";
|
||||
case otStatBlockMine: return "stat.mineBlock";
|
||||
case otStatEntityKill: return "stat.killEntity";
|
||||
case otStatEntityKilledBy: return "stat.entityKilledBy";
|
||||
|
||||
default: return "";
|
||||
}
|
||||
@ -46,19 +46,19 @@ cObjective::eType cObjective::StringToType(const AString & a_Name)
|
||||
const char * m_String;
|
||||
} TypeMap [] =
|
||||
{
|
||||
{E_TYPE_DUMMY, "dummy"},
|
||||
{E_TYPE_DEATH_COUNT, "deathCount"},
|
||||
{E_TYPE_PLAYER_KILL_COUNT, "playerKillCount"},
|
||||
{E_TYPE_TOTAL_KILL_COUNT, "totalKillCount"},
|
||||
{E_TYPE_HEALTH, "health"},
|
||||
{E_TYPE_ACHIEVEMENT, "achievement"},
|
||||
{E_TYPE_STAT, "stat"},
|
||||
{E_TYPE_STAT_ITEM_CRAFT, "stat.craftItem"},
|
||||
{E_TYPE_STAT_ITEM_USE, "stat.useItem"},
|
||||
{E_TYPE_STAT_ITEM_BREAK, "stat.breakItem"},
|
||||
{E_TYPE_STAT_BLOCK_MINE, "stat.mineBlock"},
|
||||
{E_TYPE_STAT_ENTITY_KILL, "stat.killEntity"},
|
||||
{E_TYPE_STAT_ENTITY_KILLED_BY, "stat.entityKilledBy"}
|
||||
{otDummy, "dummy" },
|
||||
{otDeathCount, "deathCount" },
|
||||
{otPlayerKillCount, "playerKillCount" },
|
||||
{otTotalKillCount, "totalKillCount" },
|
||||
{otHealth, "health" },
|
||||
{otAchievement, "achievement" },
|
||||
{otStat, "stat" },
|
||||
{otStatItemCraft, "stat.craftItem" },
|
||||
{otStatItemUse, "stat.useItem" },
|
||||
{otStatItemBreak, "stat.breakItem" },
|
||||
{otStatBlockMine, "stat.mineBlock" },
|
||||
{otStatEntityKill, "stat.killEntity" },
|
||||
{otStatEntityKilledBy, "stat.entityKilledBy"}
|
||||
};
|
||||
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;
|
||||
}
|
||||
} // 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)
|
||||
{
|
||||
for (int i = 0; i < (int) E_DISPLAY_SLOT_COUNT; ++i)
|
||||
for (int i = 0; i < (int) dsCount; ++i)
|
||||
{
|
||||
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)
|
||||
{
|
||||
ASSERT(a_Slot < E_DISPLAY_SLOT_COUNT);
|
||||
ASSERT(a_Slot < dsCount);
|
||||
|
||||
cObjective * Objective = GetObjective(a_Objective);
|
||||
|
||||
@ -448,7 +448,7 @@ void cScoreboard::SetDisplay(cObjective * a_Objective, 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];
|
||||
}
|
||||
@ -524,7 +524,7 @@ void cScoreboard::SendTo(cClientHandle & 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
|
||||
cObjective * Objective = m_Display[i];
|
||||
|
@ -31,23 +31,23 @@ public:
|
||||
|
||||
enum eType
|
||||
{
|
||||
E_TYPE_DUMMY,
|
||||
otDummy,
|
||||
|
||||
E_TYPE_DEATH_COUNT,
|
||||
E_TYPE_PLAYER_KILL_COUNT,
|
||||
E_TYPE_TOTAL_KILL_COUNT,
|
||||
E_TYPE_HEALTH,
|
||||
otDeathCount,
|
||||
otPlayerKillCount,
|
||||
otTotalKillCount,
|
||||
otHealth,
|
||||
|
||||
E_TYPE_ACHIEVEMENT,
|
||||
otAchievement,
|
||||
|
||||
E_TYPE_STAT,
|
||||
E_TYPE_STAT_ITEM_CRAFT,
|
||||
E_TYPE_STAT_ITEM_USE,
|
||||
E_TYPE_STAT_ITEM_BREAK,
|
||||
otStat,
|
||||
otStatItemCraft,
|
||||
otStatItemUse,
|
||||
otStatItemBreak,
|
||||
|
||||
E_TYPE_STAT_BLOCK_MINE,
|
||||
E_TYPE_STAT_ENTITY_KILL,
|
||||
E_TYPE_STAT_ENTITY_KILLED_BY
|
||||
otStatBlockMine,
|
||||
otStatEntityKill,
|
||||
otStatEntityKilledBy
|
||||
};
|
||||
|
||||
// tolua_end
|
||||
@ -201,11 +201,11 @@ public:
|
||||
|
||||
enum eDisplaySlot
|
||||
{
|
||||
E_DISPLAY_SLOT_LIST = 0,
|
||||
E_DISPLAY_SLOT_SIDEBAR,
|
||||
E_DISPLAY_SLOT_NAME,
|
||||
dsList = 0,
|
||||
dsSidebar,
|
||||
dsName,
|
||||
|
||||
E_DISPLAY_SLOT_COUNT
|
||||
dsCount
|
||||
};
|
||||
|
||||
// tolua_end
|
||||
@ -284,7 +284,7 @@ private:
|
||||
|
||||
cWorld * m_World;
|
||||
|
||||
cObjective* m_Display[E_DISPLAY_SLOT_COUNT];
|
||||
cObjective * m_Display[dsCount];
|
||||
|
||||
friend class cScoreboardSerializer;
|
||||
|
||||
|
@ -173,13 +173,13 @@ void cScoreboardSerializer::SaveScoreboardToNBT(cFastNBTWriter & a_Writer)
|
||||
|
||||
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());
|
||||
|
||||
Objective = m_ScoreBoard->GetObjectiveIn(cScoreboard::E_DISPLAY_SLOT_SIDEBAR);
|
||||
Objective = m_ScoreBoard->GetObjectiveIn(cScoreboard::dsSidebar);
|
||||
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.EndCompound(); // DisplaySlots
|
||||
@ -280,7 +280,7 @@ bool cScoreboardSerializer::LoadScoreboardFromNBT(const cParsedNBT & a_NBT)
|
||||
{
|
||||
AString Name, DisplayName, Prefix, Suffix;
|
||||
|
||||
bool AllowsFriendlyFire = false, CanSeeFriendlyInvisible = false;
|
||||
bool AllowsFriendlyFire = true, CanSeeFriendlyInvisible = false;
|
||||
|
||||
int CurrLine = a_NBT.FindChildByName(Child, "Name");
|
||||
if (CurrLine >= 0)
|
||||
@ -346,7 +346,7 @@ bool cScoreboardSerializer::LoadScoreboardFromNBT(const cParsedNBT & a_NBT)
|
||||
{
|
||||
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");
|
||||
@ -354,7 +354,7 @@ bool cScoreboardSerializer::LoadScoreboardFromNBT(const cParsedNBT & a_NBT)
|
||||
{
|
||||
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");
|
||||
@ -362,7 +362,7 @@ bool cScoreboardSerializer::LoadScoreboardFromNBT(const cParsedNBT & a_NBT)
|
||||
{
|
||||
AString Name = a_NBT.GetString(CurrLine);
|
||||
|
||||
m_ScoreBoard->SetDisplay(Name, cScoreboard::E_DISPLAY_SLOT_NAME);
|
||||
m_ScoreBoard->SetDisplay(Name, cScoreboard::dsName);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user