-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
14 changed files
with
562 additions
and
106 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
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 @@ | ||
cd ~/checkout/OneLife/server; echo 1 > settings/forceShutdownMode.ini; sleep 2; git checkout settings/forceShutdownMode.ini |
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 \ | ||
|
||
|
||
|
||
|
Oops, something went wrong.