Skip to content

Commit

Permalink
Changes to function of /DIE. Can no longer use it to cycle through al…
Browse files Browse the repository at this point in the history
…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
jasonrohrer committed May 27, 2019
1 parent 03c6fde commit 2419cdf
Show file tree
Hide file tree
Showing 5 changed files with 197 additions and 17 deletions.
11 changes: 11 additions & 0 deletions documentation/changeLog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,17 @@ Version 235 ???



Server Fixes

--Changes to function of /DIE. Can no longer use it to cycle through all
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.




Version 234 2019-May-25

Expand Down
112 changes: 112 additions & 0 deletions server/familySkipList.cpp
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;
}

15 changes: 15 additions & 0 deletions server/familySkipList.h
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 );
1 change: 1 addition & 0 deletions server/makeFileList
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ curseLog.cpp \
spiral.cpp \
objectSurvey.cpp \
language.cpp \
familySkipList.cpp \



Expand Down
75 changes: 58 additions & 17 deletions server/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
#include "lineageLimit.h"
#include "objectSurvey.h"
#include "language.h"
#include "familySkipList.h"


#include "minorGems/util/random/JenkinsRandomSource.h"
Expand Down Expand Up @@ -1325,7 +1326,7 @@ void quitCleanup() {
freeObjectSurvey();

freeLanguage();

freeFamilySkipList();

freeTriggers();

Expand Down Expand Up @@ -5197,6 +5198,31 @@ int processLoggedInPlayer( Socket *inSock,
}
else {
// baby



// filter parent choices by this baby's skip list
SimpleVector<LiveObject *>
filteredParentChoices( parentChoices.size() );

for( int i=0; i<parentChoices.size(); i++ ) {
LiveObject *p = parentChoices.getElementDirect( i );

if( ! isSkipped( inEmail, p->lineageEveID ) ) {
filteredParentChoices.push_back( p );
}
}

if( filteredParentChoices.size() == 0 ) {
// baby has skipped everyone

// clear their list and let them start over again
clearSkipList( inEmail );

filteredParentChoices.push_back_other( &parentChoices );
}



// pick random mother from a weighted distribution based on
// each mother's temperature
Expand All @@ -5205,8 +5231,8 @@ int processLoggedInPlayer( Socket *inSock,

int maxYumMult = 1;

for( int i=0; i<parentChoices.size(); i++ ) {
LiveObject *p = parentChoices.getElementDirect( i );
for( int i=0; i<filteredParentChoices.size(); i++ ) {
LiveObject *p = filteredParentChoices.getElementDirect( i );

int yumMult = p->yummyFoodChain.size() - 1;

Expand All @@ -5226,8 +5252,8 @@ int processLoggedInPlayer( Socket *inSock,

double totalWeight = 0;

for( int i=0; i<parentChoices.size(); i++ ) {
LiveObject *p = parentChoices.getElementDirect( i );
for( int i=0; i<filteredParentChoices.size(); i++ ) {
LiveObject *p = filteredParentChoices.getElementDirect( i );

// temp part of weight
totalWeight += 0.5 - fabs( p->heat - 0.5 );
Expand All @@ -5249,8 +5275,8 @@ int processLoggedInPlayer( Socket *inSock,

totalWeight = 0;

for( int i=0; i<parentChoices.size(); i++ ) {
LiveObject *p = parentChoices.getElementDirect( i );
for( int i=0; i<filteredParentChoices.size(); i++ ) {
LiveObject *p = filteredParentChoices.getElementDirect( i );

totalWeight += 0.5 - fabs( p->heat - 0.5 );

Expand Down Expand Up @@ -8400,6 +8426,7 @@ int main() {
initObjectSurvey();

initLanguage();
initFamilySkipList();


initTriggers();
Expand Down Expand Up @@ -13546,16 +13573,30 @@ int main() {
double yearsLived =
getSecondsPlayed( nextPlayer ) * getAgeRate();

if( ! nextPlayer->isTutorial )
recordLineage( nextPlayer->email,
nextPlayer->originalBirthPos,
yearsLived,
// count true murder victims here, not suicide
( killerID > 0 && killerID != nextPlayer->id ),
// killed other or committed SID suicide
nextPlayer->everKilledAnyone ||
nextPlayer->suicide );

if( ! nextPlayer->isTutorial ) {

recordLineage(
nextPlayer->email,
nextPlayer->originalBirthPos,
yearsLived,
// count true murder victims here, not suicide
( killerID > 0 && killerID != nextPlayer->id ),
// killed other or committed SID suicide
// CHANGE:
// no longer count SID toward lineage ban
// we added this family to baby's skip
// list below
nextPlayer->everKilledAnyone );

if( nextPlayer->suicide ) {
// add to player's skip list
skipFamily( nextPlayer->email,
nextPlayer->lineageEveID );
}
}



if( ! nextPlayer->deathLogged ) {
char disconnect = true;

Expand Down

0 comments on commit 2419cdf

Please sign in to comment.