-
Notifications
You must be signed in to change notification settings - Fork 280
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changes to function of /DIE. Can no longer use it to cycle through al…
…l families and force yourself to be an unecessary Eve. Eve only spawns if there are really no available motehrs for an incoming baby. /DIE adds this family to your family skip list. If you eventually cycle through all families, so that you've skipped them all, and none are left, your skip list is cleared.
- Loading branch information
1 parent
03c6fde
commit 2419cdf
Showing
5 changed files
with
197 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
#include "familySkipList.h" | ||
|
||
#include "minorGems/util/SimpleVector.h" | ||
#include "minorGems/util/stringUtils.h" | ||
#include "minorGems/system/Time.h" | ||
|
||
|
||
|
||
typedef struct FamilySkipListRecord { | ||
char *babyEmail; | ||
|
||
SimpleVector<int> *skippedLineageList; | ||
|
||
double lastUpdateTime; | ||
} FamilySkipListRecord; | ||
|
||
|
||
static void freeRecordMembers( FamilySkipListRecord *inR ) { | ||
delete [] inR->babyEmail; | ||
delete inR->skippedLineageList; | ||
} | ||
|
||
SimpleVector<FamilySkipListRecord> skipListRecords; | ||
|
||
|
||
|
||
void initFamilySkipList() { | ||
} | ||
|
||
|
||
|
||
void freeFamilySkipList() { | ||
for( int i=0; i<skipListRecords.size(); i++ ) { | ||
FamilySkipListRecord *r = skipListRecords.getElement( i ); | ||
freeRecordMembers( r ); | ||
} | ||
skipListRecords.deleteAll(); | ||
} | ||
|
||
|
||
|
||
// makes new one if one doesn't exist, if requested, | ||
// or returns NULL if not found | ||
static FamilySkipListRecord *findRecord( char *inBabyEmail, | ||
char inMakeNew = false ) { | ||
double curTime = Time::getCurrentTime(); | ||
|
||
for( int i=0; i<skipListRecords.size(); i++ ) { | ||
FamilySkipListRecord *r = skipListRecords.getElement( i ); | ||
|
||
if( strcmp( r->babyEmail, inBabyEmail ) == 0 ) { | ||
return r; | ||
} | ||
else if( curTime - r->lastUpdateTime > 7200 ) { | ||
// record not touched for 2 hours | ||
freeRecordMembers( r ); | ||
skipListRecords.deleteElement( i ); | ||
i--; | ||
} | ||
} | ||
|
||
// no matching email found | ||
|
||
if( ! inMakeNew ) { | ||
return NULL; | ||
} | ||
|
||
FamilySkipListRecord newR = | ||
{ stringDuplicate( inBabyEmail ), | ||
new SimpleVector<int>(), | ||
curTime }; | ||
|
||
skipListRecords.push_back( newR ); | ||
|
||
return skipListRecords.getElement( skipListRecords.size() - 1 ); | ||
} | ||
|
||
|
||
|
||
void skipFamily( char *inBabyEmail, int inLineageEveID ) { | ||
FamilySkipListRecord *r = findRecord( inBabyEmail, true ); | ||
|
||
r->skippedLineageList->push_back( inLineageEveID ); | ||
} | ||
|
||
|
||
|
||
void clearSkipList( char *inBabyEmail ) { | ||
FamilySkipListRecord *r = findRecord( inBabyEmail ); | ||
|
||
if( r != NULL ) { | ||
r->skippedLineageList->deleteAll(); | ||
} | ||
} | ||
|
||
|
||
|
||
char isSkipped( char *inBabyEmail, int inLineageEveID ) { | ||
|
||
FamilySkipListRecord *r = findRecord( inBabyEmail ); | ||
|
||
if( r == NULL ) { | ||
return false; | ||
} | ||
|
||
if( r->skippedLineageList->getElementIndex( inLineageEveID ) != -1 ) { | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
|
||
|
||
void initFamilySkipList(); | ||
|
||
|
||
void freeFamilySkipList(); | ||
|
||
|
||
void skipFamily( char *inBabyEmail, int inLineageEveID ); | ||
|
||
|
||
void clearSkipList( char *inBabyEmail ); | ||
|
||
|
||
char isSkipped( char *inBabyEmail, int inLineageEveID ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,6 +53,7 @@ curseLog.cpp \ | |
spiral.cpp \ | ||
objectSurvey.cpp \ | ||
language.cpp \ | ||
familySkipList.cpp \ | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters