-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathCAdventureRecord.cpp
97 lines (71 loc) · 1.91 KB
/
CAdventureRecord.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
// CAdventureRecord.cpp
//
// CAdventureRecord class
// Copyright (c) 2012 by Kronosaur Productions, LLC. All Rights Reserved.
#include "PreComp.h"
CAdventureRecord::CAdventureRecord (DWORD dwAdventure, int iHighScoreCount) :
m_dwAdventure(dwAdventure)
// CAdventureRecord constructor
{
if (iHighScoreCount > 0)
m_HighScores.InsertEmpty(iHighScoreCount);
}
bool CAdventureRecord::FindRecordByGameID (const CString &sGameID, DWORD *retdwID) const
// FindRecordByGameID
//
// Looks for a game record with the given gameID. We look in the special
// section first (callers rely on this).
{
int i;
for (i = 0; i < specialIDCount; i++)
if (strEquals(m_Special[i].GetGameID(), sGameID))
{
if (retdwID)
*retdwID = specialIDFirst + i;
return true;
}
for (i = 0; i < m_HighScores.GetCount(); i++)
if (strEquals(m_HighScores[i].GetGameID(), sGameID))
{
if (retdwID)
*retdwID = i;
return true;
}
return false;
}
CString CAdventureRecord::GetAdventureName (void) const
// GetAdventureName
//
// Get the name of the adventure
{
CExtension *pAdventure;
if (!g_pUniverse->FindExtension(m_dwAdventure, 0, &pAdventure))
return strPatternSubst(CONSTLIT("Adventure %x"), m_dwAdventure);
return pAdventure->GetName();
}
CGameRecord &CAdventureRecord::GetRecordAt (DWORD dwID)
// GetRecordAt
//
// Returns the given record
{
// If this is a special ID, then return the appropriate record.
if (dwID >= specialIDFirst && (dwID - specialIDFirst) < specialIDCount)
return m_Special[dwID - specialIDFirst];
// Otherwise see if we can return a record from the high score list
else if (dwID < (DWORD)m_HighScores.GetCount())
return m_HighScores[dwID];
// Otherwise, this is an error
else
{
ASSERT(false);
return m_Special[specialIDFirst];
}
}
void CAdventureRecord::Init (DWORD dwAdventure)
// Init
//
// Initialize
{
m_HighScores.DeleteAll();
m_dwAdventure = dwAdventure;
}