-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathCUserProfile.cpp
62 lines (45 loc) · 1.15 KB
/
CUserProfile.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
// CUserProfile.cpp
//
// CUserProfile class
// Copyright (c) 2012 by Kronosaur Productions, LLC. All Rights Reserved.
#include "PreComp.h"
bool CUserProfile::FindAdventureRecord (DWORD dwAdventure, int *retiIndex)
// FindAdventureRecord
//
// Looks for the given adventure record
{
int i;
for (i = 0; i < m_Records.GetCount(); i++)
if (m_Records[i].GetAdventureUNID() == dwAdventure)
{
if (retiIndex)
*retiIndex = i;
return true;
}
return false;
}
void CUserProfile::Init (const CString &sUsername)
// Init
//
// Initialize
{
m_sUsername = sUsername;
m_Records.DeleteAll();
}
CAdventureRecord &CUserProfile::InsertAdventureRecord (DWORD dwAdventure)
// InsertAdventureRecord
//
// Inserts a new adventure record or returns an existing one.
//
// NOTE: The object returns from this call is only valid until the next call
// to InsertAdventureRecord.
{
// Look for the adventure. If we find it, return it.
int iIndex;
if (FindAdventureRecord(dwAdventure, &iIndex))
return m_Records[iIndex];
// Otherwise, we add it
CAdventureRecord *pNewRecord = m_Records.Insert();
pNewRecord->Init(dwAdventure);
return *pNewRecord;
}