Skip to content
This repository has been archived by the owner on Nov 5, 2024. It is now read-only.

Commit

Permalink
Password log to keep a record of the passwords you said
Browse files Browse the repository at this point in the history
  • Loading branch information
risvh committed Sep 15, 2023
1 parent 388fab6 commit 820c965
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
58 changes: 58 additions & 0 deletions gameSource/LivingLifePage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@

#include <stdlib.h>//#include <math.h>
#include <string>
#include <fstream>


#define OHOL_NON_EDITOR 1
Expand Down Expand Up @@ -384,6 +385,30 @@ static void clearLocationSpeech() {
}


static SimpleVector<char*> passwordProtectingPhrases;

static void readPhrases( const char *inSettingsName,
SimpleVector<char*> *inList ) {
char *cont = SettingsManager::getSettingContents( inSettingsName, "" );

if( strcmp( cont, "" ) == 0 ) {
delete [] cont;
return;
}

int numParts;
char **parts = split( cont, "\n", &numParts );
delete [] cont;

for( int i=0; i<numParts; i++ ) {
if( strcmp( parts[i], "" ) != 0 ) {
inList->push_back( stringToUpperCase( parts[i] ) );
}
delete [] parts[i];
}
delete [] parts;
}



// most recent home at end
Expand Down Expand Up @@ -3285,6 +3310,8 @@ LivingLifePage::LivingLifePage()
mMapGlobalOffset.y = 0;

emotDuration = SettingsManager::getFloatSetting( "emotDuration", 10 );

readPhrases( "passwordProtectingPhrases", &passwordProtectingPhrases );

drunkEmotionIndex =
SettingsManager::getIntSetting( "drunkEmotionIndex", 2 );
Expand Down Expand Up @@ -27095,6 +27122,36 @@ void LivingLifePage::keyDown( unsigned char inASCII ) {

if (!vogMode) { // hetuw mod
HetuwMod::Say(typedText);

bool matched = false;
std::string typedTextStr = typedText;
for( int i=0; i<passwordProtectingPhrases.size(); i++ ) {
char *phrase = passwordProtectingPhrases.getElementDirect( i );
if( typedTextStr.rfind(phrase, 0) == 0 ) {
matched = true;
break;
}
}

if( matched ) {
LiveObject *ourLiveObject = getOurLiveObject();
int xd = 9999;
int yd = 9999;
if( ourLiveObject != NULL ) {
xd = ourLiveObject->xd;
yd = ourLiveObject->yd;
}

std::ofstream ofs( "passwordLog.txt", std::ios_base::app);
ofs << autoSprintf( "%f", game_getCurrentTime() );
ofs << " ";
ofs << autoSprintf( "%d %d", xd, yd );
ofs << " ";
ofs << typedTextStr;
ofs << std::endl;
ofs.close();
}

} else {
// jasons code

Expand All @@ -27109,6 +27166,7 @@ void LivingLifePage::keyDown( unsigned char inASCII ) {
sayCommand, typedText );
sendToServerSocket( message );
delete [] message;

}
}

Expand Down
2 changes: 2 additions & 0 deletions gameSource/settings/passwordProtectingPhrases.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
PASSWORD IS
MAGIC WORD IS

0 comments on commit 820c965

Please sign in to comment.