Skip to content

Commit

Permalink
Add new commands /reborn and /tutorial (hetuw#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMingo888 authored Oct 18, 2023
1 parent 48d31fd commit ad3974b
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 1 deletion.
35 changes: 34 additions & 1 deletion gameSource/LivingLifePage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2773,6 +2773,7 @@ void LivingLifePage::clearMap() {

LivingLifePage::LivingLifePage()
: mServerSocket( -1 ),
mServerSocketOld( -1 ),
mForceRunTutorial( 0 ),
mTutorialNumber( 0 ),
mGlobalMessageShowing( false ),
Expand Down Expand Up @@ -3324,6 +3325,11 @@ LivingLifePage::~LivingLifePage() {
mServerSocket = -1;
}

if ( mServerSocketOld != -1 ) {
closeSocket( mServerSocketOld );
mServerSocketOld = -1;
}

for( int j=0; j<2; j++ ) {
mPreviousHomeDistStrings[j].deallocateStringElements();
mPreviousHomeDistFades[j].deleteAll();
Expand Down Expand Up @@ -6634,7 +6640,7 @@ void LivingLifePage::draw( doublePair inViewCenter,
drawMessage( "waitingArrival", pos );
HetuwMod::drawWaitingText(pos);
}
else if( userTwinCode == NULL ) {
else if( userTwinCode == NULL || userTwinCount == 1 ) {
drawMessage( "waitingBirth", pos );
HetuwMod::drawWaitingText(pos);
}
Expand Down Expand Up @@ -13062,6 +13068,11 @@ void LivingLifePage::step() {
}


if ( mServerSocketOld != -1 && pageLifeTime > 10 ) {
// YumLife: close old socket after reconnecting due to /reborn or /tutorial
closeSocket( mServerSocketOld );
mServerSocketOld = -1;
}


if( pageLifeTime < 1 ) {
Expand Down Expand Up @@ -26531,6 +26542,28 @@ void LivingLifePage::keyDown( unsigned char inASCII ) {
"orderCommand" ) ) {
sendToServerSocket( (char*)"ORDR 0 0#" );
}
else if( commandTyped( typedText, "/REBORN" ) ||
commandTyped( typedText, "/TUTORIAL" ) ) {
// YumLife mod
if ( computeCurrentAge( ourLiveObject ) < 2 ) {
char *message = autoSprintf( "DIE 0 0#" );
sendToServerSocket( message );
delete [] message;
}
else {
if ( mServerSocketOld != -1 ) {
closeSocket( mServerSocketOld );
}
mServerSocketOld = mServerSocket;
mServerSocket = -1;
if( commandTyped( typedText, "/REBORN" ) ) {
setSignal( "reborn" );
}
else {
setSignal( "tutorial" );
}
}
}
else {
// filter hints
char *filterString =
Expand Down
1 change: 1 addition & 0 deletions gameSource/LivingLifePage.h
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,7 @@ class LivingLifePage : public GamePage, public ActionListener {
protected:

int mServerSocket;
int mServerSocketOld;

int mRequiredVersion;

Expand Down
21 changes: 21 additions & 0 deletions gameSource/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2137,6 +2137,27 @@ void drawFrame( char inUpdate ) {
else if( livingLifePage->checkSignal( "disconnect" ) ) {
showReconnectPage();
}
else if( livingLifePage->checkSignal( "reborn" ) ) {
// YumLife mod
if( userTwinCode != NULL ) {
delete [] userTwinCode;
userTwinCode = NULL;
}
userTwinCode = stringDuplicate( "yumlife_reborn" );
userTwinCount = 1;
startConnecting();
}
else if( livingLifePage->checkSignal( "tutorial" ) ) {
// YumLife mod
if( userTwinCode != NULL ) {
delete [] userTwinCode;
userTwinCode = NULL;
}
userTwinCode = stringDuplicate( "yumlife_tutorial" );
userTwinCount = 1;
livingLifePage->runTutorial( 1 );
startConnecting();
}
else if( livingLifePage->checkSignal( "loadFailure" ) ) {
currentGamePage = finalMessagePage;

Expand Down

0 comments on commit ad3974b

Please sign in to comment.