/* -------------------------------------------------------------------- */ void newgroup(void) { label groupname; int slot, i; getString("group", groupname, NAMESIZE, FALSE, ECHO, ""); if ( (groupexists(groupname) != ERROR) || !strlen(groupname) ) { mPrintf("\n We already have a \'%s\' group.", groupname); return; } /* search for a free group slot */ for (i = 0, slot = 0; i < MAXGROUPS && !slot ; i++) { if (!grpBuf.group[i].g_inuse) slot = i; } if (!slot) { mPrintf("\n Group table full."); return; } getString("group description", grpBuf.group[slot].desc, 79, FALSE, ECHO,""); grpBuf.group[slot].lockout = (getYesNo("Lock group from aides", 0 )); grpBuf.group[slot].hidden = (getYesNo("Hide group", 0 )); grpBuf.group[slot].autoAdd = (getYesNo("Auto-Add group", 0 )); strcpy(grpBuf.group[slot].groupname, groupname); grpBuf.group[slot].g_inuse = 1; /* increment group generation # */ grpBuf.group[slot].groupgen = (uchar)((grpBuf.group[slot].groupgen + 1) % MAXGROUPGEN); if (getYesNo(confirm, 0)) { putGroup(); sprintf(msgBuf->mbtext, "Group %s created", grpBuf.group[slot].groupname ); trap(msgBuf->mbtext, T_SYSOP); logBuf.groups[slot] = grpBuf.group[slot].groupgen; storeLog(); } else { getGroup(); } }
/* -------------------------------------------------------------------- */ xhallfunc(int roomslot, int xyn, int fl) { int yn; if (hallBuf->hall[thisHall].hroomflags[roomslot].inhall) { yn=getYesNo("Exclude from hall", (char)xyn); if (yn == 2) return FALSE; if (yn) { hallBuf->hall[thisHall].hroomflags[roomslot].inhall = FALSE; sprintf(msgBuf->mbtext, "Room %s excluded from hall %s by %s", roomTab[roomslot].rtname, hallBuf->hall[thisHall].hallname, logBuf.lbname ); trap(msgBuf->mbtext, T_AIDE); if (!fl) { aideMessage(); }else{ amPrintf(" Excluded %s\n", roomTab[roomslot].rtname, hallBuf->hall[thisHall].hallname); changed_room = TRUE; } } }else{ yn=getYesNo("Add to hall", (char)xyn); if (yn == 2) return FALSE; if (yn) { hallBuf->hall[thisHall].hroomflags[roomslot].inhall = TRUE; sprintf(msgBuf->mbtext, "Room %s added to hall %s by %s", roomTab[roomslot].rtname, hallBuf->hall[thisHall].hallname, logBuf.lbname ); trap(msgBuf->mbtext, T_AIDE); if (!fl) { aideMessage(); }else{ amPrintf(" Added %s\n", roomTab[roomslot].rtname); changed_room = TRUE; } } } return TRUE; }
/* -------------------------------------------------------------------- */ void killhall(void) { int empty = TRUE, i; if (thisHall == 0 || thisHall == 1) { mPrintf("\nThe Main and Maintenance hallways cannot be killed."); return; } /* Check hall for any rooms */ for (i = 0; i < MAXROOMS; i++) { if ( hallBuf->hall[thisHall].hroomflags[i].inhall && roomTab[i].rtflags.INUSE) empty = FALSE; } if (!empty) { mPrintf("\n Hall still has rooms."); return; } if (getYesNo(confirm, 0)) { hallBuf->hall[thisHall].h_inuse = FALSE; hallBuf->hall[thisHall].owned = FALSE; putHall(); sprintf(msgBuf->mbtext, "Hallway %s deleted", hallBuf->hall[thisHall].hallname ); trap(msgBuf->mbtext, T_SYSOP); } }
string Options::getValueString(OptionId id) { Value value = getValue(id); switch (id) { case OptionId::HINTS: case OptionId::ASCII: case OptionId::FULLSCREEN: case OptionId::AUTOSAVE: case OptionId::WASD_SCROLLING: case OptionId::SOUND: case OptionId::MUSIC: return getOnOff(value); case OptionId::KEEP_SAVEFILES: case OptionId::SHOW_MAP: case OptionId::FAST_IMMIGRATION: case OptionId::STARTING_RESOURCE: case OptionId::ONLINE: case OptionId::ZOOM_UI: case OptionId::START_WITH_NIGHT: return getYesNo(value); case OptionId::ADVENTURER_NAME: case OptionId::KEEPER_SEED: case OptionId::KEEPER_NAME: { string val = boost::get<string>(value); if (val.empty()) return defaultStrings[id]; else return val; } case OptionId::FULLSCREEN_RESOLUTION: return choices[id][boost::get<int>(value)]; case OptionId::MAIN_VILLAINS: case OptionId::LESSER_VILLAINS: case OptionId::RETIRED_VILLAINS: case OptionId::INFLUENCE_SIZE: case OptionId::ALLIES: return toString(getIntValue(id)); } }
/************************************************************************ * * doLogout() handles T(erminate) command * * Parameters: * * char expand TRUE to accept following parameters * char first first parameter if TRUE * ************************************************************************/ void doLogout(char expand, char first) { char done = FALSE, verbose = FALSE; if (expand) first = '\0'; mPrintf("\bTerminate "); if (first) oChar(first); if (first == 'q') verbose = 1; while (!done) { done = TRUE; switch (toupper(first ? (int) first : (int) iChar())) { case '?': mPrintf("\n Logout options:\n \n "); mPrintf("Q>uit-also\n "); mPrintf("S>tay on line\n "); mPrintf("V>erbose\n "); mPrintf("? -- this\n "); break; case 'Y': case 'Q': mPrintf("\bQuit-also\n "); if (!expand) { if (!getYesNo(confirm, 0)) break; } if (!(haveCarrier || onConsole)) break; terminate( /* hangUp == */ TRUE, verbose); break; case 'S': mPrintf("\bStay\n "); terminate( /* hangUp == */ FALSE, verbose); break; case 'V': mPrintf("\bVerbose "); verbose = 2; done = FALSE; break; default: if (gl_user.expert) mPrintf("? "); else mPrintf("? for help"); break; } first = '\0'; } }
void showHelp(int mode) //parodo pagalba { if(mode==1) { if(!getYesNo("\nAr parodyti pagalba? [Y/n]\n>> ")) return; } //show help from predefined string }
/* -------------------------------------------------------------------- */ void killgroup(void) { label groupname; int groupslot, i; getString("group", groupname, NAMESIZE, FALSE, ECHO, ""); groupslot = groupexists(groupname); if ( groupslot == 0 || groupslot == 1) { mPrintf("\n Cannot delete Null or Reserved_2 groups."); return; } if ( groupslot == ERROR || !strlen(groupname) ) { mPrintf("\n No such group."); return; } for (i = 0; i < MAXROOMS; i++) { if ( roomTab[i].rtflags.INUSE && roomTab[i].rtflags.GROUPONLY && (roomTab[i].grpno == (unsigned char)groupslot) /* && (roomTab[i].grpgen == grpBuf.group[groupslot].groupgen)*/ ) { mPrintf("\n Group still has rooms."); return; } } for (i = 0; i < MAXHALLS; i++) { if ( hallBuf->hall[i].h_inuse && hallBuf->hall[i].owned && hallBuf->hall[i].grpno == (unsigned char)groupslot) { mPrintf("\n Group still has hallways."); return; } } if (!getYesNo(confirm, 0)) return; grpBuf.group[groupslot].g_inuse = 0; putGroup(); sprintf(msgBuf->mbtext, "Group %s deleted", groupname ); trap(msgBuf->mbtext, T_SYSOP); }
int play_again() { char ans; printf ("\nDo you wish to try another game"); ans = getYesNo(); if (ans == 'Y') return (1); else return (0); }
void crop_yield_and_losses() { int j1; char ans; C = FNX(2) + 3.0; if (((int)(nY/7) * 7) == nY) { printf ("Seven year locusts\n"); C = C / 2.0; } X1 = 0.0; for (j1=1;j1<=5;j1++) X1 = X1 + U[j1] * (1.2 - 0.2 * j1); if (G[8] == 0) { C1 = 0.0; C = 0.0; } else { C1 = (int)(C * (float)((X1/G[8]) * 100) / 100.0); C = C1; } printf ("Yield = %8.2f HL./HA.\n", C); X1 = (float)(FNX(3) + 3.0); if (X1 < 9.0) return; G[5] = -(int)((X1 * nG) / 83); nG = nG + G[5]; printf ("Rats infest the grainery\n"); if ((nP < 67) || (K == -1)) return; X1 = (float)(FNX(4)); if (X1 > (nP / 30.0)) return; printf ("The High King requires %d peasants for his estates\n", (int) X1); printf ("and mines. Will you supply them (Yes) or pay %d\n", (int)(X1 * 100.0)); printf ("HL. of grain instead (No)"); ans = getYesNo(); if (ans == 'N') { G[10] = -100.0 * X1; nG = nG + G[10]; return; } P[3] = -X1; nP = nP + P[3]; return; }
/* -------------------------------------------------------------------- */ void windowfunc(void) { if (hallBuf->hall[thisHall].hroomflags[thisRoom].window) { if (getYesNo("Unwindow",0)) { hallBuf->hall[thisHall].hroomflags[thisRoom].window = FALSE; sprintf(msgBuf->mbtext, "Hall %s made invisible from room %s> by %s", hallBuf->hall[thisHall].hallname, roomBuf.rbname, logBuf.lbname ); trap(msgBuf->mbtext, T_AIDE); aideMessage(); } } else if (getYesNo("Window",0)) { hallBuf->hall[thisHall].hroomflags[thisRoom].window = TRUE; sprintf(msgBuf->mbtext, "Hall %s made visible from room %s> by %s", hallBuf->hall[thisHall].hallname, roomBuf.rbname, logBuf.lbname ); trap(msgBuf->mbtext, T_AIDE); aideMessage(); } putHall(); }
void TERMWINDOWMEMBER purgeuserlog(void) { Bool done = FALSE; for (l_slot i = (l_slot) (cfg.MAXLOGTAB - 1); i >= 0 && !done; i--) { if (LTab(i).IsInuse()) { label UserName; LTab(i).GetName(UserName, sizeof(UserName)); if (!loggedIn || !CurrentUser->IsSameName(UserName)) { char prompt[256]; sprintf(prompt, getsysmsg(57), cfg.Luser_nym, UserName); const int response = getYesNo(prompt, 3); if (response == 1) { LogEntry1 Log1; Log1.Clear(); if (Log1.Save(LTab(i).GetLogIndex())) { if(!read_tr_messages()) { errorDisp(getmsg(172)); done = TRUE; return; } #ifdef WINCIT trap(T_SYSOP, WindowCaption, gettrmsg(16), UserName); #else trap(T_SYSOP, gettrmsg(16), UserName); #endif dump_tr_messages(); } } else if (response == 2) { done = TRUE; } } } } }
void introduction() { char ans; printf ("\nD U K E D O M\n"); printf ("Microcomputer Version\n"); printf ("\nDo you want instructions"); ans = getYesNo(); if (ans == 'Y') printf ("sorry - not ready yet\n"); F3 = 2; M = 1.95; return; }
TILE selectTile(TILE board[], TILE last) { int cmd; int x = last.x, y = last.y; do { jumpTo(xsp(x), ysp(y)); cmd = getch(); switch (cmd) { case 'w': y -= y > 0 ? 1 : -10; break; case 's': y += y < 10 ? 1 : -10; break; case 'a': x -= x > 0 ? 1 : -10; break; case 'd': x += x < 10 ? 1 : -10; break; case 224: // arrow key may have been pressed switch (getch()) { case UPKEYCODE: y -= y > 0 ? 1 : -10; break; case DOWNKEYCODE: y += y < 10 ? 1 : -10; break; case LEFTKEYCODE: x -= x > 0 ? 1 : -10; break; case RIGHTKEYCODE: x += x < 10 ? 1 : -10; break; } break; case 27: // escape printErrorString(7); // Abort game? (Y/N) if (getYesNo()) { memset(&last, 0, sizeof last); return last; } printErrorString(0); // clear "Abort game?"-prompt break; } } while (! (cmd == 13 || cmd == ' ')); // return key or space can be used to select tile return board[y*11+x]; }
int end_of_game_check() { char ans; if (nP < 33) { printf ("You have so few peasants left that\n"); printf ("the High King has abolished your Ducal right\n\n"); return (1); } if (nL < 199) { printf ("You have so little land left that\n"); printf ("the High King has abolished your Ducal right\n\n"); return (1); } if (nG < 429) { printf ("You have so little grain left that\n"); printf ("the High King has abolished your Ducal right\n\n"); return (1); } if ((U1 > 88) || (U2 > 99)) { deposed(); return (1); } if ((nY > 45) && (K == 0)) { printf ("You have reached the age of mandatory retirement\n"); return (1); } U1 = 0; if (K > 0) { printf ("The King demands twice the royal tax in the\n"); printf ("hope of provoking war. Will you pay"); ans = getYesNo(); K = 2; if (ans == 'N') K = -1; } return (0); }
/* -------------------------------------------------------------------- */ char *matchString(char *buf, char *pattern, char *bufEnd, char ver) { char *loc, *pc1, *pc2; char subbuf[11]; char foundIt; subbuf[10] = '\0'; for (loc = bufEnd, foundIt = FALSE; !foundIt && --loc >= buf;) { for (pc1 = pattern, pc2 = loc, foundIt = TRUE; *pc1 && foundIt;) { if (!(tolower(*pc1++) == tolower(*pc2++))) foundIt = FALSE; } if (ver && foundIt) { doCR(); strncpy(subbuf, buf + 10 > loc ? buf : loc - 10, (unsigned) (loc - buf) > 10 ? 10 : (unsigned) (loc - buf)); subbuf[(unsigned) (loc - buf) > 10 ? 10 : (unsigned) (loc - buf)] = 0; mPrintf("%s", subbuf); if (gl_term.ansiOn) termCap(TERM_BOLD); else mPrintf(">"); mPrintf("%s", pattern); if (gl_term.ansiOn) termCap(TERM_NORMAL); else mPrintf("<"); strncpy(subbuf, loc + strlen(pattern), 10); subbuf[10] = 0; mPrintf("%s", subbuf); if (!getYesNo("Replace", 0)) foundIt = FALSE; } } return foundIt ? loc : NULL; }
/* -------------------------------------------------------------------- */ void killuser(void) { label who; int logno; getNormStr("who", who, NAMESIZE, ECHO); logno = findPerson(who, &lBuf); if (logno == ERROR || !strlen(who)) { mPrintf("No \'%s\' known. \n ", who); return; } if (strcmpi(logBuf.lbname, who) == SAMESTRING) { mPrintf("Cannot kill your own account, log out first.\n"); return; } if (!getYesNo(confirm, 0)) return; mPrintf( "\'%s\' terminated.\n ", who); /* trap it */ sprintf(msgBuf->mbtext, "User %s terminated", who); trap(msgBuf->mbtext, T_SYSOP); lBuf.lbname[0] = '\0'; lBuf.lbin[ 0] = '\0'; lBuf.lbpw[ 0] = '\0'; lBuf.lbflags.L_INUSE = FALSE; lBuf.lbflags.PERMANENT = FALSE; putLog(&lBuf, logno); }
string Options::getValueString(OptionId id, Options::Value value) { switch (id) { case OptionId::HINTS: case OptionId::ASCII: case OptionId::FULLSCREEN: case OptionId::AUTOSAVE: case OptionId::MUSIC: return getOnOff(value); case OptionId::KEEP_SAVEFILES: case OptionId::SHOW_MAP: case OptionId::FAST_IMMIGRATION: case OptionId::STARTING_RESOURCE: case OptionId::ONLINE: case OptionId::START_WITH_NIGHT: return getYesNo(value); case OptionId::ADVENTURER_NAME: case OptionId::KEEPER_NAME: { string val = boost::get<string>(value); if (val.empty()) return defaultStrings[id]; else return val; } case OptionId::FULLSCREEN_RESOLUTION: return choices[id][boost::get<int>(value)]; } }
/* -------------------------------------------------------------------- */ void fkey(void) { char key; int oldIO, i, oldDowhat; label string; #define F1 59 #define F2 60 #define F3 61 #define F4 62 #define F5 63 #define F6 64 #define S_F6 89 #define A_F6 109 #define F7 65 #define F8 66 #define F9 67 #define F10 68 #define ALT_P 25 #define ALT_D 32 #define ALT_B 48 #define ALT_L 38 #define ALT_T 20 #define ALT_X 45 #define ALT_C 46 #define ALT_E 18 key = (char)getch(); if (strcmpi(cfg.f6pass, "f6disabled") != SAMESTRING) if (ConLock == TRUE && key == ALT_L && strcmpi(cfg.f6pass, "disabled") != SAMESTRING) { ConLock = FALSE; oldIO = whichIO; whichIO = CONSOLE; onConsole = TRUE; update25(); string[0] = 0; getNormStr("System Password", string, NAMESIZE, NO_ECHO); if (strcmpi(string, cfg.f6pass) != SAMESTRING) ConLock = TRUE; whichIO = (BOOL)oldIO; onConsole = (BOOL)(whichIO == CONSOLE); update25(); givePrompt(); return; } if (ConLock && !sysop && strcmpi(cfg.f6pass, "f6disabled") != SAMESTRING) return; switch(key) { case F1: drop_dtr(); detectflag = FALSE; break; case F2: Initport(); detectflag = FALSE; break; case F3: sysReq = (BOOL)(!sysReq); break; case F4: ScreenFree(); anyEcho = (BOOL)(!anyEcho); break; case F5: if (whichIO == CONSOLE) whichIO = MODEM; else whichIO = CONSOLE; onConsole = (BOOL)(whichIO == CONSOLE); break; case S_F6: if (!ConLock) aide = (BOOL)(!aide); break; case A_F6: if (!ConLock) sysop = (BOOL)(!sysop); break; case F6: if (sysop || !ConLock) sysopkey = TRUE; break; case F7: cfg.noBells = !cfg.noBells; break; case ALT_C: case F8: chatkey = (BOOL)(!chatkey); /* will go into chat from main() */ break; case F9: cfg.noChat = !cfg.noChat; chatReq = FALSE; break; case F10: help(); break; case ALT_B: backout = (BOOL)(!backout); break; case ALT_D: debug = (BOOL)(!debug); break; case ALT_E: eventkey = TRUE; break; case ALT_L: if (cfg.f6pass[0] && strcmpi(cfg.f6pass, "f6disabled") != SAMESTRING) ConLock = (BOOL)(!ConLock); break; case ALT_P: if (printing) { printing=FALSE; fclose(printfile); }else{ printfile=fopen(cfg.printer, "a"); if (printfile) { printing=TRUE; } else { printing=FALSE; fclose(printfile); } } break; case ALT_T: twit = (BOOL)(!twit); break; case ALT_X: if (dowhat == MAINMENU || dowhat == SYSOPMENU) { oldDowhat = dowhat; if (loggedIn) { i = getYesNo("Exit to MS-DOS", 0); } else { doCR(); doCR(); mPrintf("Exit to MS-DOS"); doCR(); i = TRUE; } dowhat = oldDowhat; if (!i) { if (dowhat == MAINMENU) { givePrompt(); }else{ doCR(); mPrintf("2Privileged function:0 "); } break; } ExitToMsdos = TRUE; } break; default: break; } update25(); }
char doRegular(char expand, char c) { char toReturn; int i; int done = 0; label doorinfo; toReturn = FALSE; for (i = 0; !expand && i < MAXEXTERN && extCmd[i].name[0]; ++i) { if (c == toupper(extCmd[i].name[0]) && (onConsole || !extCmd[i].local)) { done = 1; mPrintf("\b%s", extCmd[i].name); doCR(); if (changedir(cfg.aplpath) == ERROR) { mPrintf(" -- Can't find application directory.\n\n"); changedir(cfg.homepath); } /* apsystem(extCmd[i].command); */ sprintf(doorinfo, "DORINFO%d.DEF", onConsole ? 0 : userdat.apl_com); extFmtRun(extCmd[i].command, doorinfo); } } if (!done) { switch (c) { case 'S': if (gl_user.sysop && expand) { mPrintf("\b\bSysop Menu"); doCR(); doSysop(); } else { toReturn = TRUE; } break; case 'A': if (gl_user.aide) { doAide(expand, 'E'); } else { toReturn = TRUE; } break; case 'C': doChat(expand, '\0'); break; case 'D': doDownload(expand); break; case 'E': doEnter(expand, 'm'); break; case 'F': doRead(expand, 'f'); break; case 'G': doGoto(expand, FALSE); break; case 'H': doHelp(expand); break; case 'I': doIntro(); break; case 'J': mPrintf("\bJump back to "); unGotoRoom(); break; case 'K': doKnown(expand, 'r'); break; case 'L': if (!loggedIn) { doLogin(expand); } else { if (!getYesNo(confirm, 0)) break; doLogout(expand, 's'); doLogin(expand); } break; case 'N': case 'O': case 'R': doRead(expand, tolower(c)); break; case 'B': doGoto(expand, TRUE); break; case 'T': doLogout(expand, 'q'); break; case 'U': doUpload(expand); break; case 'X': if (!expand) { doEnter(expand, 'x'); } else { doXpert(); } break; case '=': case '+': doNext(); break; case '\b': mPrintf(" "); case '-': doPrevious(); break; case ']': case '>': doNextHall(); break; case '[': case '<': doPreviousHall(); break; case '~': mPrintf("\bAnsi %s\n ", gl_term.ansiOn ? gl_str.off : gl_str.on); gl_term.ansiOn = !gl_term.ansiOn; break; case '!': mPrintf("\bIBM Graphics %s\n ", gl_term.IBMOn ? gl_str.off:gl_str.on); gl_term.IBMOn = !gl_term.IBMOn; break; case '?': nextmenu("mainopt", &(cfg.cnt.mainopttut), 1); listExterns(); break; case 0: /* never gets here in shell mode... */ if (newCarrier) { greeting(); if (cfg.forcelogin) { doCR(); doCR(); i = 0; while (!loggedIn && gotCarrier()) { doLogin(2); if (++i > 3) { Initport(); toReturn = TRUE; break; } } } newCarrier = FALSE; } if (logBuf.lbflags.NODE && loggedIn) { net_slave(); haveCarrier = FALSE; modStat = FALSE; newCarrier = FALSE; justLostCarrier = FALSE; onConsole = FALSE; disabled = FALSE; callout = FALSE; delay(2000); Initport(); cfg.callno++; terminate(FALSE, FALSE); } if (justLostCarrier || ExitToMsdos) { justLostCarrier = FALSE; if (loggedIn) terminate(FALSE, FALSE); } break; /* irrelevant value */ default: toReturn = TRUE; break; } } /* if they get unverified online */ if (logBuf.VERIFIED) terminate(FALSE, FALSE); /* update25(); */ do_idle(0); return toReturn; }
/* -------------------------------------------------------------------- */ void loginNew(char *initials, char *password) { int i; ulong newpointer; if (getYesNo(cfg.l_verified ? " No record: Enter as new user" : " No record: Request access", 1)) { if (!CARRIER) return; if (cfg.l_closedsys && (!sysopNew && !(onConsole && !debug))) { tutorial("closesys.blb"); drop_dtr(); return; } tutorial("userinfo.blb"); if (cfg.l_create || sysopNew || (onConsole && !debug)) { logBuf.VERIFIED = (onConsole && !debug) ? FALSE : !cfg.l_verified; newUser(initials, password); if (!loggedIn) return; newaccount(); update25(); } if (cfg.l_questionare && (!(onConsole && !debug))) { newUserFile(); } if (cfg.l_application && (!(onConsole && !debug))) { if (changedir(cfg.aplpath) == ERROR) { mPrintf(" -- Can't find application directory.\n\n"); changedir(cfg.homepath); return; } apsystem(cfg.newuserapp); changedir(cfg.homepath); } if (cfg.l_sysop_msg && (!(onConsole && !debug))) { tutorial("newmsg.blb"); i = loggedIn; /* force to sysop */ loggedIn = FALSE; mailFlag = TRUE; oldFlag = FALSE; limitFlag = FALSE; linkMess = FALSE; makeMessage(); loggedIn = (uchar)i; } if (logBuf.VERIFIED && !sysopNew && loggedIn) { verbose = FALSE; terminate(TRUE); mPrintf("\n Thank you, Good Bye.\n"); Hangup(); } } /**********************************************************************/ /* Icky Hack designed to make #oldcount functional */ /* this was moved here because for some reason making messages */ /* was causing the pointers to get screwed up */ /**********************************************************************/ if (cfg.oldcount) { newpointer = (cfg.newest - cfg.oldcount); if (newpointer < cfg.oldest) newpointer = cfg.oldest; /* logBuf.lbvisit[0] = newpointer; */ /* pushed down later by setlbvisit() */ for (i = 0; i < MAXROOMS; i++) { logBuf.newpointer[i] = newpointer; /* logBuf.lbroom[i].lvisit = 0; */ /* becomes==1 later by setlbvisit() */ } } /**********************************************************************/ /* ^^^ Disgusting? Wasn't it? ^^^ Hope it works! */ /**********************************************************************/ sysopNew = FALSE; return; }
Bool TERMWINDOWMEMBER killuser(const char *name) { label who; l_slot logno; char line[80]; if (!name) { SetDoWhat(SYSKUSER); } if (name) { CopyStringToBuffer(who, name); } else { getNormStr(cfg.Luser_nym, who, LABELSIZE); } if (!*who) { return (FALSE); } logno = FindPersonByPartialName(who); if (logno == CERROR) { if (!name) { mPrintfCR(getmsg(595), who); } return (FALSE); } LTab(logno).GetName(who, sizeof(who)); if (loggedIn && CurrentUser->IsSameName(who)) { if (!name) { mPrintfCR(getsysmsg(83)); } return (FALSE); } sprintf(line, getsysmsg(84), cfg.Luser_nym, who); if (!name && !getYesNo(line, 0)) { return (FALSE); } else { LogEntry1 Log1; if (!name) { CRmPrintfCR(getsysmsg(85), who); } Log1.Clear(); if (Log1.Save(LTab(logno).GetLogIndex())) { if(!(read_tr_messages())) { errorDisp(getmsg(172)); return(FALSE); } #ifdef WINCIT trap(T_SYSOP, WindowCaption, gettrmsg(16), who); #else trap(T_SYSOP, gettrmsg(16), who); #endif dump_tr_messages(); } return (TRUE); } }
void messWithShareList (uchar bUsage, label roomname) { struct messNode nodeArray[MAXDIRECT] ; int i, j, iNode, iTopNode, iOn ; uchar fKeyFound, fAnyPrinted, fQuit, fDisplayMenu ; char ch, oldEcho, path[255], buf[255], *lpch, *lpstr, aHotKeys[] = "BCDEFGHIJKLMNOPQRTUVWXYZ1234567890!#$%&*(", *words[256]; int hFile ; /* Initialize the array. */ for (i = 0; i < MAXDIRECT; i++) { strcpy (nodeArray[i].nodeName, '\0') ; nodeArray[i].fShared = FALSE ; nodeArray[i].bHotKey = (uchar) 0 ; nodeArray[i].bHotKeyPos = (uchar) 0 ; } /* In one single pass, we're going to read the NODES file and fill out */ /* our array based on all the information we find there! */ sprintf (path, "%s\\NODES.CIT", cfg.homepath) ; hFile = sopen (path, O_TEXT | O_RDONLY, SH_DENYNO) ; if (-1 == hFile) crashout ("Problem opening NODES.CIT.") ; iTopNode = -1 ; while ( !eof(hFile) ) { if (!sfgets (buf, 255, hFile)) break ; /* Error reading file. */ if ('#' != buf[0]) /* It's not a keyword. */ continue ; if (strnicmp (buf, "#NODE", 5) == SAMESTRING) { parse_it (words, buf) ; if (words[1] == NULL) /* Invalid #NODE entry. */ continue ; /* We have a new node and its name! */ ++iTopNode ; strcpy (nodeArray[iTopNode].nodeName, words[1]) ; } else { if (strnicmp (buf, "#ROOM", 5) != SAMESTRING) continue ; if (-1 == iTopNode) /* We don't have a node yet. */ continue ; parse_it (words, buf) ; if (stricmp (words[1], roomname) == SAMESTRING) nodeArray[iTopNode].fShared = TRUE ; } } close (hFile) ; /* For the short, non-interactive output, just spew it out and quit. */ if (SHORT_SEE_NO_MODIFY == bUsage) { if (-1 == iTopNode) mPrintf ("(No nodes in NODES.CIT.)") ; else { iOn = 0 ; fAnyPrinted = FALSE ; while (iOn <= iTopNode) { if (TRUE == nodeArray[iOn].fShared) { if (fAnyPrinted) mPrintf ("3, 0%s", nodeArray[iOn].nodeName) ; else { mPrintf ("%s", nodeArray[iOn].nodeName) ; fAnyPrinted = TRUE ; } } ++iOn ; } if (fAnyPrinted) mPrintf ("3.0") ; } return ; } if (SEE_WITH_MODIFY == bUsage) { /* If we found more nodes than we can hotkey, say so and abort. */ if (iTopNode >= (int) strlen (aHotKeys)) { mPrintf ("Uh-oh! There are too many nodes in the userlog to use this function.") ; doCR() ; return ; } /* Hotkeys are determined by a priority system. First, we try to */ /* get the first character of the node name. Second, we try for */ /* the first character following every space in the name. Third, */ /* we try every character in the name. Last, we scan the entire */ /* hotkey string until we find an unused key. */ for (iNode = 0; iNode <= iTopNode; iNode++) { fKeyFound = FALSE ; /* PLAN ONE: Try for the first character. */ ch = (char) toupper (*nodeArray[iNode].nodeName) ; lpch = strchr (aHotKeys, ch) ; if (lpch) /* If char = valid hotkey... */ { nodeArray[iNode].bHotKey = *lpch ; nodeArray[iNode].bHotKeyPos = 0 ; *lpch = FILLED ; /* Ptr into aHotKeys */ continue ; /* Do the next node. */ } /* PLAN TWO: Try for the first letter of every word. Since i */ /* starts at one, it's ok to check the previous character for */ /* a space. */ lpstr = nodeArray[iNode].nodeName ; i = 1 ; while (lpstr[i]) /* While we're not on the final NULL... */ { if ( ' ' == lpstr[i-1] ) /* Is the prev char a space? */ { ch = (char) toupper (lpstr[i]) ; lpch = strchr (aHotKeys, ch) ; if (lpch) /* Valid chr? */ { nodeArray[iNode].bHotKey = *lpch ; nodeArray[iNode].bHotKeyPos = (uchar) i ; *lpch = FILLED ; /* Ptr into aHotKeys */ fKeyFound = TRUE ; /* Signal release from for iter.*/ break ; /* Releases from while loop. */ } } ++i ; } /* If the above loop found a key, move on to the next node. */ if (fKeyFound) continue ; /* PLAN THREE: Check every single character in the string for */ /* a valid hot key. */ i = 0 ; while (lpstr[i]) /* While we're not on the final NULL... */ { ch = (char) toupper (lpstr[i]) ; lpch = strchr (aHotKeys, ch) ; if (lpch) /* Valid chr? */ { nodeArray[iNode].bHotKey = *lpch ; nodeArray[iNode].bHotKeyPos = (uchar) i ; *lpch = FILLED ; /* Ptr into aHotKeys */ fKeyFound = TRUE ; /* Signal release from for iter. */ break ; /* Releases from while loop. */ } ++i ; } /* If the above loop found a key, move on to the next node. */ if (fKeyFound) continue ; /* PLAN FOUR: Give the node the first available hot key. */ /* Checking done previously assures that we'll get one. */ i = 0 ; while (FILLED == aHotKeys[i]) ++i ; nodeArray[iNode].bHotKey = aHotKeys[i] ; nodeArray[iNode].bHotKeyPos = NOT_IN_STRING ; aHotKeys[i] = FILLED ; } fDisplayMenu = TRUE ; fQuit = FALSE ; for (;;) { if (fDisplayMenu) { doCR () ; for (iNode = 0; iNode <= iTopNode; iNode++) { strcpy (buf, ".........................") ; lpstr = nodeArray[iNode].nodeName ; i = j = 0 ; while (lpstr[i] != '\0') /* Doesn't copy the NULL */ { if ( i == (int) nodeArray[iNode].bHotKeyPos) /* Turn on bold */ { buf[j] = '' ; buf[j+1] = '3' ; buf[j+2] = lpstr[i] ; buf[j+3] = '' ; buf[j+4] = '0' ; j += 5 ; } else { buf[j] = lpstr[i] ; ++j ; } ++i ; } mPrintf ("<3%c0> %s %s", nodeArray[iNode].bHotKey, buf, nodeArray[iNode].fShared ? "YES" : "No") ; doCR() ; } } /* Take user input. */ doCR() ; mPrintf("<3S0> to save, <3A0> to abort."); doCR(); fDisplayMenu = (BOOL)(!expert) ; outFlag = IMPERVIOUS; doCR(); mPrintf("2Add/Drop:0 "); oldEcho = echo; echo = NEITHER; ch = (char) iChar(); echo = oldEcho; if (!((whichIO == CONSOLE) || gotCarrier())) return; switch(toupper(ch)) { case 'A': mPrintf("Abort"); doCR(); if (getYesNo("Abort", TRUE)) return; break; case 'S': mPrintf("Save"); doCR(); if (getYesNo("Save", TRUE)) { saveNewReality(nodeArray, roomname, iTopNode) ; return ; } break ; case '\r': case '\n': case '?' : mPrintf("Menu"); doCR(); fDisplayMenu = TRUE; break; default: /* Check if for hotkey and toggle right entry. */ for (i = 0; i <= iTopNode; i++) if (toupper(ch) == nodeArray[i].bHotKey) { nodeArray[i].fShared = (uchar) !nodeArray[i].fShared ; mPrintf ("%s %s", nodeArray[i].nodeName, nodeArray[i].fShared ? "added." : "dropped.") ; doCR() ; break ; } /* If it fails to break above, it's not valid input. */ if (i > iTopNode) { mPrintf("%c ? for help", ch); doCR(); break ; } } } /* This is in the right place. */ } }
void renameRoom(void) { char pathname[64]; char summary[500]; label roomname; label oldname; label groupname; char line[80]; char waspublic; int groupslot; char description[13]; int roomslot; BOOL prtMess = TRUE; BOOL quit = FALSE; int c; char oldEcho; strcpy(oldname,roomBuf.rbname); if (!roomBuf.rbflags.MSDOSDIR) { roomBuf.rbdirname[0] = '\0'; } doCR(); do { if (prtMess) { doCR(); outFlag = OUTOK; mPrintf("<3N0> Name.............. %s", roomBuf.rbname); doCR(); mPrintf("<3I0> Infoline.......... %s", roomBuf.descript); doCR(); mPrintf("<3D0> Directory......... %s", roomBuf.rbflags.MSDOSDIR ? roomBuf.rbdirname : "None"); doCR(); mPrintf("<3L0> Application....... %s", roomBuf.rbflags.APLIC ? roomBuf.rbaplic : "None"); doCR(); mPrintf("<3F0> Description File.. %s", roomBuf.rbroomtell[0] ? roomBuf.rbroomtell : "None"); doCR(); mPrintf("<3G0> Access Group...... %s", roomBuf.rbflags.GROUPONLY ? grpBuf.group[roomBuf.rbgrpno].groupname : "None"); doCR(); mPrintf("<3V0> PriVileges Group.. %s", roomBuf.rbflags.PRIVGRP ? grpBuf.group[roomBuf.rbPgrpno].groupname : "None"); doCR(); if (roomBuf.rbflags.PRIVGRP) { mPrintf(" Download only..... %s", roomBuf.rbflags.DOWNONLY ? "Yes" : "No" ); doCR(); mPrintf(" Upload only....... %s", roomBuf.rbflags.UPONLY ? "Yes" : "No" ); doCR(); mPrintf(" Read Only......... %s", roomBuf.rbflags.READONLY ? "Yes" : "No" ); doCR(); mPrintf(" Group moderates... %s", roomBuf.rbflags.GRP_MOD ? "Yes" : "No" ); doCR(); } mPrintf("<3H0> Hidden............ %s", roomBuf.rbflags.PUBLIC ? "No" : "Yes" ); doCR(); mPrintf("<3Y0> Anonymous......... %s", roomBuf.rbflags.ANON ? "Yes" : "No" ); doCR(); mPrintf("<3O0> BIO............... %s", roomBuf.rbflags.BIO ? "Yes" : "No" ); doCR(); mPrintf("<3M0> Moderated......... %s", roomBuf.rbflags.MODERATED ? "Yes" : "No" );doCR(); #ifdef NETWORK mPrintf("<3E0> Networked/Shared.. %s", roomBuf.rbflags.SHARED ? "Yes" : "No" ); doCR(); if (roomBuf.rbflags.SHARED) { mPrintf ("<3W0> Shared With....... ") ; messWithShareList (SHORT_SEE_NO_MODIFY, oldname) ; doCR() ; } #endif /* NETWORK */ mPrintf("<3P0> Permanent......... %s", roomBuf.rbflags.PERMROOM ? "Yes" : "No" ); doCR(); mPrintf("<3U0> Subject........... %s", roomBuf.rbflags.SUBJECT ? "Yes" : "No" ); doCR(); doCR(); mPrintf("<3S0> to save, <3A0> to abort."); doCR(); prtMess = (BOOL)(!expert); } outFlag = IMPERVIOUS; doCR(); mPrintf("2Change:0 "); oldEcho = echo; echo = NEITHER; c = iChar(); echo = oldEcho; if (!CARRIER) return; switch(toupper(c)) { case 'L': mPrintf("Application"); doCR(); if (sysop && onConsole) { if ( getYesNo("Application", (uchar)(roomBuf.rbflags.APLIC) ) ) { getString("Application filename", description, 13, FALSE, ECHO, (roomBuf.rbaplic[0]) ? roomBuf.rbaplic : ""); strcpy(roomBuf.rbaplic, description); roomBuf.rbflags.APLIC = TRUE; } else { roomBuf.rbaplic[0] = '\0'; roomBuf.rbflags.APLIC = FALSE; } } else { mPrintf("Must be Sysop at console to enter application."); doCR(); } break; case 'N': mPrintf("Name"); doCR(); getString("New room name", roomname, NAMESIZE, FALSE, ECHO, roomBuf.rbname); normalizeString(roomname); roomslot = roomExists(roomname); if (roomslot >= 0 && roomslot != thisRoom) { mPrintf("A \"%s\" room already exists.\n", roomname); } else { strcpy(roomBuf.rbname, roomname); /* also in room itself */ } break; case 'I': mPrintf("Info-line \n "); getNormStr("New room Info-line", roomBuf.descript, 79, ECHO); break; case 'D': mPrintf("Directory"); doCR(); if (sysop) { if (getYesNo("Directory room", (uchar)roomBuf.rbflags.MSDOSDIR)) { roomBuf.rbflags.MSDOSDIR = TRUE; if (!roomBuf.rbdirname[0]) mPrintf(" No drive and path"); else mPrintf(" Now space %s",roomBuf.rbdirname); doCR(); getString("Path", pathname, 63, FALSE, ECHO, (roomBuf.rbdirname[0]) ? roomBuf.rbdirname : cfg.dirpath); pathname[0] = (char)toupper(pathname[0]); doCR(); mPrintf("Checking pathname \"%s\"", pathname); doCR(); if (directory_l(pathname) && !onConsole) { logBuf.VERIFIED = TRUE; sprintf(msgBuf->mbtext, "Security violation on dirctory %s by %s\n " "User unverified.", pathname, logBuf.lbname); aideMessage(); doCR(); mPrintf("Security violation, your account is being " "held for sysop's review"); doCR(); Hangup(); getRoom(thisRoom); return; } if (changedir(pathname) != -1) { mPrintf(" Now space %s", pathname); doCR(); strcpy(roomBuf.rbdirname, pathname); } else { mPrintf("%s does not exist! ", pathname); if (getYesNo("Create", 0)) { if (mkdir(pathname) == -1) { mPrintf("mkdir() ERROR!"); strcpy(roomBuf.rbdirname, cfg.temppath); } else { strcpy(roomBuf.rbdirname, pathname); mPrintf(" Now space %s",roomBuf.rbdirname); doCR(); } } else { strcpy(roomBuf.rbdirname, cfg.temppath); } } if (roomBuf.rbflags.PRIVGRP && roomBuf.rbflags.MSDOSDIR) { roomBuf.rbflags.DOWNONLY = getYesNo("Download only", (uchar)roomBuf.rbflags.DOWNONLY); if (!roomBuf.rbflags.DOWNONLY) { roomBuf.rbflags.UPONLY = getYesNo("Upload only", (uchar)roomBuf.rbflags.UPONLY); } } } else { roomBuf.rbflags.MSDOSDIR = FALSE; roomBuf.rbflags.DOWNONLY = FALSE; } changedir(cfg.homepath); } else { doCR(); mPrintf("Must be Sysop to make directories."); doCR(); } break; case 'F': mPrintf("Description File"); doCR(); if (cfg.roomtell && sysop) { if ( getYesNo("Display room description File", (uchar)(roomBuf.rbroomtell[0] != '\0') ) ) { getString("Description Filename", description, 13, FALSE, ECHO, (roomBuf.rbroomtell[0]) ? roomBuf.rbroomtell : ""); strcpy(roomBuf.rbroomtell, description); } else roomBuf.rbroomtell[0] = '\0'; } else { doCR(); mPrintf("Must be Sysop and have Room descriptions configured."); doCR(); } break; case 'G': mPrintf("Access Group"); doCR(); if ((thisRoom > 2) || (thisRoom > 0 && sysop)) { if (getYesNo("Change Group", 0)) { getString("Group for room <CR> for no group", groupname, NAMESIZE, FALSE, ECHO, ""); roomBuf.rbflags.GROUPONLY = TRUE; groupslot = partialgroup(groupname); if (!strlen(groupname) || (groupslot == ERROR) ) { roomBuf.rbflags.GROUPONLY = 0; if (groupslot == ERROR && strlen(groupname)) mPrintf("No such group."); } if (roomBuf.rbflags.GROUPONLY) { roomBuf.rbgrpno = (unsigned char)groupslot; /* roomBuf.rbgrpgen = grpBuf.group[groupslot].groupgen;*/ } } } else { if(thisRoom > 0) { doCR(); mPrintf("Must be Sysop to change group for Mail> or Aide)"); doCR(); } else { doCR(); mPrintf("Lobby> can never be group only"); doCR(); } } break; case 'V': mPrintf("Privileges Group"); doCR(); if (getYesNo("Change Group", 0)) { getString("Group for room <CR> for no group", groupname, NAMESIZE, FALSE, ECHO, ""); roomBuf.rbflags.PRIVGRP = TRUE; groupslot = partialgroup(groupname); if (!strlen(groupname) || (groupslot == ERROR) ) { roomBuf.rbflags.PRIVGRP = FALSE; roomBuf.rbflags.READONLY = FALSE; roomBuf.rbflags.DOWNONLY = FALSE; roomBuf.rbflags.UPONLY = FALSE; roomBuf.rbflags.GRP_MOD = FALSE; if (groupslot == ERROR && strlen(groupname)) mPrintf("No such group."); } if (roomBuf.rbflags.PRIVGRP ) { roomBuf.rbPgrpno = (unsigned char)groupslot; /* roomBuf.rbPgrpgen = grpBuf.group[groupslot].groupgen; */ } } if (roomBuf.rbflags.PRIVGRP) { roomBuf.rbflags.READONLY = getYesNo("Read only", (uchar)roomBuf.rbflags.READONLY); roomBuf.rbflags.GRP_MOD = getYesNo("Group Moderates", (uchar)roomBuf.rbflags.GRP_MOD); if (roomBuf.rbflags.MSDOSDIR) { roomBuf.rbflags.DOWNONLY = getYesNo("Download only", (uchar)roomBuf.rbflags.DOWNONLY); if (!roomBuf.rbflags.DOWNONLY) { roomBuf.rbflags.UPONLY = getYesNo("Upload only", (uchar)roomBuf.rbflags.UPONLY); } } } break; case 'H': mPrintf("Hidden Room"); doCR(); if ((thisRoom > 2) || (thisRoom>0 && sysop)) { waspublic = (uchar)roomBuf.rbflags.PUBLIC; roomBuf.rbflags.PUBLIC = !getYesNo("Hidden room", (uchar)(!roomBuf.rbflags.PUBLIC)); if (waspublic && (!roomBuf.rbflags.PUBLIC)) { roomBuf.rbgen = (uchar)((roomBuf.rbgen +1) % MAXGEN); logBuf.lbroom[thisRoom].lbgen = roomBuf.rbgen; } } else { doCR(); mPrintf("Must be Sysop to make Lobby>, Mail> or Aide) hidden."); doCR(); } break; case 'Y': mPrintf("Anonymous Room"); doCR(); if ((thisRoom > 2) || (thisRoom>0 && sysop)) { roomBuf.rbflags.ANON = getYesNo("Anonymous room", (uchar)(roomBuf.rbflags.ANON)); } else { doCR(); mPrintf("Must be Sysop to make Lobby>, Mail> or Aide) Anonymous."); doCR(); } break; case 'O': mPrintf("BIO Room"); doCR(); if ((thisRoom > 2) || (thisRoom>0 && sysop)) { roomBuf.rbflags.BIO = getYesNo("BIO room", (uchar)(roomBuf.rbflags.BIO)); } else { doCR(); mPrintf("Must be Sysop to make Lobby>, Mail> or Aide) BIO."); doCR(); } break; case 'M': mPrintf("Moderated"); doCR(); if (sysop) { if (getYesNo("Moderated", (uchar)(roomBuf.rbflags.MODERATED) )) roomBuf.rbflags.MODERATED = TRUE; else roomBuf.rbflags.MODERATED = FALSE; } else { doCR(); mPrintf("Must be Sysop to make Moderated rooms."); doCR(); } break; #ifdef NETWORK case 'E': mPrintf("Networked/Shared"); doCR(); if (sysop) { /* Perhaps rooms made shareable should also automatically */ /* become permenant, as well. */ BOOL fShared = (BOOL) roomBuf.rbflags.SHARED ; roomBuf.rbflags.SHARED = getYesNo("Networked/Shared room", (uchar)fShared) ; if ((roomBuf.rbflags.SHARED) && (!fShared)) roomBuf.rbflags.PERMROOM = TRUE ; } else { doCR(); mPrintf("Must be Sysop to make Shared rooms."); doCR(); } break; case 'W': mPrintf ("Shared With"); doCR(); if (roomBuf.rbflags.SHARED) messWithShareList (SEE_WITH_MODIFY, oldname) ; else { doCR() ; mPrintf ("Unshared rooms don't have share lists.") ; doCR() ; } break ; #endif /* NETWORK */ case 'P': mPrintf("Permanent"); doCR(); if (thisRoom > DUMP) { if (!roomBuf.rbflags.MSDOSDIR) { roomBuf.rbflags.PERMROOM = getYesNo("Permanent", (uchar)roomBuf.rbflags.PERMROOM); } else { roomBuf.rbflags.PERMROOM = 1; doCR(); mPrintf("Directory rooms are always Permanent."); doCR(); } } else { doCR(); mPrintf("Lobby> Mail> Aide) or Dump> always Permanent."); doCR(); } break; case 'U': mPrintf("Subject"); doCR(); roomBuf.rbflags.SUBJECT = getYesNo("Ask for subject in room", (uchar)roomBuf.rbflags.SUBJECT); break; case 'S': mPrintf("Save"); doCR(); if (getYesNo("Save changes", FALSE)) { noteRoom(); putRoom(thisRoom); /* trap file line */ sprintf(line, "Room \'%s\' changed to \'%s\' by %s", oldname, roomBuf.rbname, logBuf.lbname); trap(line, T_AIDE); /* Aide room */ formatSummary(summary); sprintf(msgBuf->mbtext, "%s \n%s", line, summary); aideMessage(); return; } break; case 'A': mPrintf("Abort"); doCR(); if (getYesNo("Abort", TRUE)) { getRoom(thisRoom); return; } break; case '\r': case '\n': case '?': mPrintf("Menu"); doCR(); prtMess = TRUE; break; default: mPrintf("%c ? for help", c); doCR(); break; } } while (!quit); }
void TERMWINDOWMEMBER EnterRoom(Bool GroupOnly) { doCR(); if (!loggedIn) { CRmPrintfCR(getmsg(239)); return; } if (!LockMenu(MENU_ENTER)) { return; } // The user must be able to make a room, and at least one of the remaining bits if (CurrentUser->IsMakeRoom() && (cfg.nonAideRoomOk || HallData[thisHall].IsEnterRoom() || CurrentUser->IsAide())) { // There must be no limit to the number of rooms to make, be an aide, or be under the limit if (!cfg.numRooms || CurrentUser->IsAide() || roomsMade < cfg.numRooms) { label roomname; label groupname; g_slot groupslot; r_slot newSlot; Bool test; SetDoWhat(ENTERROOM); newSlot = FindFreeRoomSlot(); if (newSlot == CERROR) { mPrintf(getmsg(490), cfg.Uroom_nym); UnlockMenu(MENU_ENTER); return; } if (!CurrentUser->IsExpert()) { dispBlb(B_NEWROOM); doCR(); } do { char Prompt[128]; sprintf(Prompt, getmsg(106), cfg.Lroom_nym); do { getString(Prompt, roomname, LABELSIZE, ns); if (*roomname == '?') { MRO.Verbose = FALSE; listRooms(0); } } while (*roomname == '?'); normalizeString(roomname); if (!*roomname) { UnlockMenu(MENU_ENTER); return; } test = TRUE; if (RoomExists(roomname) != CERROR) { mPrintfCR(getmsg(105), roomname, cfg.Lroom_nym); test = FALSE; } } while (!test); CurrentRoom->Clear(); if (GroupOnly) { char String[128]; sprintf(String, getmsg(588), cfg.Lgroup_nym, cfg.Lroom_nym); do { if (!AskGroupName(groupname, ns, String, LABELSIZE, TRUE)) { CurrentRoom->Load(thisRoom); // From official release UnlockMenu(MENU_ENTER); return; } groupslot = FindGroupByPartialName(groupname, FALSE); test = TRUE; if (groupslot == CERROR || !CurrentUser->IsInGroup(groupslot)) { CRmPrintfCR(getmsg(584), cfg.Lgroup_nym); test = FALSE; } } while (!test); CurrentRoom->SetGroup(groupslot); } CurrentRoom->SetInuse(TRUE); CurrentRoom->SetGroupOnly(GroupOnly); char Prompt[128], InfoLine[80]; sprintf(Prompt, getmsg(107), cfg.Lroom_nym); getNormStr(Prompt, InfoLine, 79); CurrentRoom->SetInfoLine(InfoLine); sprintf(Prompt, getmenumsg(MENU_ENTER, 43), cfg.Lroom_nym); CurrentRoom->SetPublic(getYesNo(Prompt, 1)); sprintf(Prompt, getmenumsg(MENU_ENTER, 44), roomname, (CurrentRoom->IsPublic()) ? getmenumsg(MENU_ENTER, 45) : getmenumsg(MENU_ENTER, 46), cfg.Lroom_nym); if (!getYesNo(Prompt, 0)) { CurrentRoom->Load(thisRoom); UnlockMenu(MENU_ENTER); return; } CurrentRoom->SetName(roomname); label L; CurrentUser->GetName(L, sizeof(L)); CurrentRoom->SetCreator(L); // Make sure that there are no stray messages still in this room MessageDat.EnsureRoomEmpty(newSlot); // Borgah! VVV as if it could be BIO... if (!CurrentRoom->IsPublic() || CurrentRoom->IsBIO()) { cycleroom(newSlot, FALSE, TRUE); } else { cycleroom(newSlot, TRUE, TRUE); } CurrentRoom->Save(newSlot); // remove and unwindow room from all halls for (h_slot j = 0; j < cfg.maxhalls; j++) { HallData[j].SetRoomInHall(newSlot, FALSE); HallData[j].SetWindowedIntoHall(newSlot, FALSE); } // put room in current hall HallData[thisHall].SetRoomInHall(newSlot, TRUE); // put room in maintenance hall HallData[MAINTENANCE].SetRoomInHall(newSlot, TRUE); HallData.Save(); Message *Msg = new Message; if (Msg) { label UserName; CurrentUser->GetName(UserName, sizeof(UserName)); #ifdef WINCIT trap(T_NEWROOM, WindowCaption, getmsg(110), roomname, CurrentRoom->IsPublic() ? '>' : ')', UserName); #else trap(T_NEWROOM, getmsg(110), roomname, CurrentRoom->IsPublic() ? '>' : ')', UserName); #endif Msg->SetTextWithFormat(getmsg(457), cfg.Uroom_nym, roomname, CurrentRoom->IsPublic() ? '>' : ')', UserName); Msg->SetRoomNumber(newSlot); systemMessage(Msg); // Do it again because of funky compression stuff. Msg->SetTextWithFormat(getmsg(457), cfg.Uroom_nym, roomname, CurrentRoom->IsPublic() ? '>' : ')', UserName); if (CurrentRoom->IsGroupOnly()) { Msg->SetGroup(CurrentRoom->GetGroup()); } Msg->SetRoomNumber(AIDEROOM); systemMessage(Msg); delete Msg; } else { OutOfMemory(50); } CurrentUser->SetInRoom(newSlot, TRUE); roomsMade++; gotoRoom(roomname, FALSE, FALSE, FALSE); } else { CRmPrintfCR(getmenumsg(MENU_ENTER, 31), ltoac(cfg.numRooms), cfg.Lroom_nym); } } else { CRmPrintfCR(getmenumsg(MENU_ENTER, 32), cfg.Lrooms_nym); } UnlockMenu(MENU_ENTER); }
int war() { int done; char ans; int j1; if (K == -1) // line 5190 { printf ("The High King calls for peasant levies\n"); printf ("and hire many foreign mercenaries\n"); K = -2; return (0); // goto 6340 } X1 = (int)(11.0 - (1.5 * C)); // line 5240 if (X1 < 2.0) X1 = 2.0; if ((K != 0) || (nP <= 109) || ((17 * (nL - 400) + nG) <= 10600)) { X2 = 0; // line 5350 } else { printf ("The High King grows uneasy and may\n"); printf ("be subsidizing wars against you\n"); X1 = X1 + 2.0; // line 5310 X2 = nY + 5; } X3 = (int) FNX(5); // line 5380 if (X3 > X1) return (0); // goto 6340 printf ("A nearby Duke threatens war; "); X2 = (int)(X2 + 85.0 + (18.0 * FNX(6))); X4 = 1.2 - (U1 / 16); // line 5440 X5 = (int)(nP * X4) + 13; printf ("Will you attack first"); ans = getYesNo(); if (ans == 'N') { ; // goto 5590 - fall through } else { if (X2 >= X5) // goto 5540 { printf ("First strike failed - you need professionals\n"); P[4] = -X3 - X1 - 2; X2 = X2 + (3 * P[4]); ; // fall through to line 5570 } else { printf ("Pease negotiations were successful\n"); P[4] = -X1 - 1; // line 5510 X2 = 0; ; // goto 5570 } nP = nP + P[4]; // line 5570 if (X2 < 1) { U1 = U1 - (2*P[4]) - (3*P[5]); return (0); // goto line 6340 } } done = 0; // line 5590 while (!done) { printf ("How many mercenaries will you hire at 40 HL. each = "); V = getValue(); if (V > 75) { printf ("There are only 75 mercenaries available for hire\n"); continue; } else done = 1; } X2 = (int)((float) X2 * M); // line 5640 X5 = (int)((nP * X4) + (7 * V) + 13); X6 = X2 - (4*V) - (int)(0.25 * X5); X2 = X5 - X2; L[3] = (int)(0.8 * X2); if (-L[3] > (int)(0.67 * nL)) { printf ("You have been overrun and have lost the entire Dukedom\n"); printf ("The placement of your head atop the castle gate\n"); printf ("signifies that "); printf ("the High King has abolished your Ducal right\n\n"); return (1); } X1 = L[3]; // line 5720 for (j1=1;j1<=3;j1++) { X3 = (int)(X1 / (4 - j1)); if (-X3 <= S[j1]) X5 = X3; else X5 = -S[j1]; S[j1] = S[j1] + X5; X1 = X1 - X5; } for (j1=4;j1<=6;j1++) { if (-X1 <= S[j1]) X5 = X1; else X5 = -S[j1]; S[j1] = S[j1] + X5; X1 = X1 - X5; } if (L[3] < 399) // line 5900 { if (X2 >= 0) // line 6010 { printf ("You have won the war\n"); X4 = 0.67; G[7] = (int)(1.7 * L[3]); nG = nG + G[7]; ; // goto 6090 - fall through } else { printf ("You have lost the war\n"); // line 6070 X4 = G[8] / nL; ; // fall through to line 6090 } if (X6 <= 9) // line 6090 X6 = 0; else X6 = (int)(X6 / 10); ; // fall through to line 6130 } else { ; // line 5900 (continued) printf ("You have overrun the enemy and annexed his entire Dukedom\n"); G[7] = 3513; nG = nG + G[7]; X6 = -47; X4 = 0.55; if (K > 0) { ; // goto 6130 - fall through } else { K = 1; // line 5970 printf ("The King fears for his throne and\n"); printf ("may be planning direct action\n"); ; // goto 6130 - fall through } } if (X6 > nP) // line 6130 X6 = nP; P[4] = P[4] - X6; nP = nP - X6; G[8] = G[8] + (int)(X4 * L[3]); X6 = 40 * V; if (X6 <= nG) { G[6] = -X6; // what is P[5] in this case? } else { G[6] = -nG; P[5] = -(int)((X6 - nG) / 7) - 1; printf ("There isn't enough grain to pay the mercenaries\n"); } nG = nG + G[6]; if (-P[5] > nP) -nP; nP = nP + P[5]; nL = nL + L[3]; U1 = U1 - (2 * P[4]) - (3 * P[5]); return (0); }
/* -------------------------------------------------------------------- */ void globalgroup(void) { label groupname; int groupslot, i, yn, add, logNo; mPrintf("(A/R/[B]): "); switch (toupper( iCharNE() )) { case 'A': mPrintf("Add\n "); add = 1; break; case 'R': mPrintf("Remove\n "); add = 2; break; case '?': tutorial("grpglob.mnu"); return; case 'B': case 10: case 13: default: mPrintf("Both\n "); add = 0; break; } getString("group", groupname, NAMESIZE, FALSE, ECHO, ""); groupslot = partialgroup(groupname); if ( grpBuf.group[groupslot].hidden && !ingroup(groupslot) ) groupslot = ERROR; if ( groupslot == ERROR || !strlen(groupname) ) { mPrintf("\n No such group."); return; } if ( grpBuf.group[groupslot].lockout && !sysop ) { mPrintf("\n Group is locked."); return; } for (i = 0; i < cfg.MAXLOGTAB; i++) { if (logTab[i].ltpwhash != 0 && logTab[i].ltnmhash !=0) { logNo=logTab[i].ltlogSlot; getLog(&lBuf, logNo); /* Get out.. */ outFlag = OUTOK; if (mAbort(FALSE)) break; outFlag = IMPERVIOUS; if (lBuf.groups[groupslot] == grpBuf.group[groupslot].groupgen) { if(add == 2 || add == 0) { mPrintf(" 3%s0", lBuf.lbname); yn=getYesNo("Remove from group", 0+3); if (yn == 2) { SaveAideMess(); return; } if (yn) { lBuf.groups[groupslot] = (uchar)((grpBuf.group[groupslot].groupgen + (MAXGROUPGEN - 1)) % MAXGROUPGEN); sprintf(msgBuf->mbtext, "%s kicked out of group %s by %s", lBuf.lbname, grpBuf.group[groupslot].groupname, logBuf.lbname ); trap(msgBuf->mbtext, T_SYSOP); amPrintf(" %s\n", msgBuf->mbtext); } } } else { if (add == 0 || add == 1) { mPrintf(" 3%s0", lBuf.lbname); yn=getYesNo("Add to group", 0+3); if (yn == 2) { SaveAideMess(); return; } if (yn) { lBuf.groups[groupslot] = grpBuf.group[groupslot].groupgen; sprintf(msgBuf->mbtext, "%s added to group %s by %s", lBuf.lbname, grpBuf.group[groupslot].groupname, logBuf.lbname ); trap(msgBuf->mbtext, T_AIDE); amPrintf(" %s\n",msgBuf->mbtext); } } } putLog(&lBuf, logNo); /* see if it is us: */ if (loggedIn && strcmpi(logBuf.lbname, lBuf.lbname) == SAMESTRING) { logBuf.groups[groupslot] = lBuf.groups[groupslot]; } } } SaveAideMess(); }
/* -------------------------------------------------------------------- */ void globaluser(void) { label who; int groupslot, yn, logNo; getNormStr("who", who, NAMESIZE, ECHO); logNo = findPerson(who, &lBuf); if (logNo == ERROR || !strlen(who) ) { mPrintf("No \'%s\' known. \n ", who); return; } for(groupslot=0; groupslot < MAXGROUPS; groupslot++) { if (grpBuf.group[groupslot].g_inuse && ( !grpBuf.group[groupslot].lockout || sysop ) && ( !grpBuf.group[groupslot].hidden || ingroup(groupslot) ) ) { mPrintf(" %s", grpBuf.group[groupslot].groupname); if (lBuf.groups[groupslot] == grpBuf.group[groupslot].groupgen) { if ((yn = getYesNo("Remove from group", 3)) != 0 /*NULL*/) { if (yn == 2) { SaveAideMess(); return; } lBuf.groups[groupslot] = (uchar)((grpBuf.group[groupslot].groupgen + (MAXGROUPGEN - 1)) % MAXGROUPGEN); sprintf(msgBuf->mbtext, "%s kicked out of group %s by %s", lBuf.lbname, grpBuf.group[groupslot].groupname, logBuf.lbname ); trap(msgBuf->mbtext, T_AIDE); amPrintf(" %s\n", msgBuf->mbtext); } } else { if ((yn = getYesNo("Add to group", 3)) != /* NULL */ 0) { if (yn == 2) { SaveAideMess(); return; } lBuf.groups[groupslot] = grpBuf.group[groupslot].groupgen; sprintf(msgBuf->mbtext, "%s added to group %s by %s", lBuf.lbname, grpBuf.group[groupslot].groupname, logBuf.lbname ); trap(msgBuf->mbtext, T_SYSOP); amPrintf(" %s\n",msgBuf->mbtext); } } putLog(&lBuf, logNo); /* see if it is us: */ if (loggedIn && strcmpi(logBuf.lbname, who) == SAMESTRING) { logBuf.groups[groupslot] = lBuf.groups[groupslot]; } } } SaveAideMess(); }
main (int argc, char *argv[]) { char inFile[80]; char ans; int ans2; int done = 0; int play_again_flag = 1; int seed = 1; printf ("argc = %d\n", argc); if (argc >= 3) { printf ("argv[1] = %s, argv[2] = %s\n", argv[1], argv[2]); if (!strcmp(argv[1], "-i")) strcpy (inFile, argv[2]); printf ("inFile = %s\n", inFile); inFile_fp = fopen (inFile, "r"); if (inFile_fp == NULL) printf ("failed to open input file - %s\n", inFile); else printf ("reading commands from input file - %s\n", inFile); if (argc == 4) { printf ("argv[3] = %s\n", argv[1]); seed = atoi(argv[3]); printf ("using specified random seed = %d\n", seed); } else { printf ("using default random seed = %d\n", seed); } } else if (argc == 2) { printf ("argv[1] = %s\n", argv[1]); seed = atoi(argv[1]); printf ("using specified random seed = %d\n", seed); } else if (argc == 1) { seed = (((int) time(0)) % 100000) + 2; printf ("using generated random seed = %d\n", seed); } srand(seed); initialize(); introduction(); printf ("Do you wish to skip the detailed reports "); printf ("at the end of each year"); ans = getYesNo(); szR = ans; printf ("Do you want to play"); ans = getYesNo(); if (ans == 'Y') { printf ("okay - let's give the wheel a spin\n\n"); play_again_flag = 1; } else { printf ("ok - see ya round\n"); play_again_flag = 0; } while (play_again_flag) { start_new_game(); done = 0; while (!done) { last_years_results(); if (end_of_game_check()) { done = 1; continue; } feed_the_peasants(); if (starvation_and_unrest()) { done = 1; continue; } if (purchase_land() == 0) { if (sell_land()) { done = 1; continue; } } if (war_with_the_king()) { done = 1; continue; } grain_production(); update_land_tables(); crop_yield_and_losses(); if (war()) { done = 1; continue; } population_changes(); if (harvest_grain()) { done = 1; continue; } update_unrest(); } play_again_flag = play_again(); } exit(0); }
/* -------------------------------------------------------------------- */ void groupfunc(void) { label who; label groupname; int groupslot, logNo; getString("group", groupname, NAMESIZE, FALSE, ECHO, ""); groupslot = partialgroup(groupname); if (groupslot != ERROR) { if ( grpBuf.group[groupslot].lockout && !sysop ) groupslot = ERROR; if( grpBuf.group[groupslot].hidden && !ingroup(groupslot) && !onConsole ) groupslot = ERROR; } if ( groupslot == ERROR || !strlen(groupname) ) { mPrintf("\n No such group."); return; } getNormStr("who", who, NAMESIZE, ECHO); logNo = findPerson(who, &lBuf); if (logNo == ERROR || !strlen(who) ) { mPrintf("No \'%s\' known. \n ", who); return; } if (lBuf.groups[groupslot] == grpBuf.group[groupslot].groupgen) { if (getYesNo("Remove from group", 0)) { lBuf.groups[groupslot] = (uchar)((grpBuf.group[groupslot].groupgen + (MAXGROUPGEN - 1)) % MAXGROUPGEN); sprintf(msgBuf->mbtext, "%s kicked out of group %s by %s", lBuf.lbname, grpBuf.group[groupslot].groupname, logBuf.lbname ); trap(msgBuf->mbtext, T_AIDE); aideMessage(); } } else if (getYesNo("Add to group", 0)) { lBuf.groups[groupslot] = grpBuf.group[groupslot].groupgen; sprintf(msgBuf->mbtext, "%s added to group %s by %s", lBuf.lbname, grpBuf.group[groupslot].groupname, logBuf.lbname ); trap(msgBuf->mbtext, T_AIDE); aideMessage(); } putLog(&lBuf, logNo); /* see if it is us: */ if (loggedIn && strcmpi(logBuf.lbname, who) == SAMESTRING) { logBuf.groups[groupslot] = lBuf.groups[groupslot]; } }
/* -------------------------------------------------------------------- */ void renamegroup(void) { label groupname, newname; char desc[80]; int groupslot, locked, hidden, autoAdd; getString("group", groupname, NAMESIZE, FALSE, ECHO, ""); groupslot = partialgroup(groupname); if ( grpBuf.group[groupslot].hidden && !ingroup(groupslot) && !onConsole) groupslot = ERROR; if ( groupslot == ERROR || !strlen(groupname) ) { mPrintf("\n No such group."); return; } doCR(); mPrintf(" Group: %s ", grpBuf.group[groupslot].groupname); if (grpBuf.group[groupslot].lockout) { mPrintf("(Locked) "); } if (grpBuf.group[groupslot].hidden) { mPrintf("(Hidden) "); } if (grpBuf.group[groupslot].autoAdd) { mPrintf("(Auto-Add)"); } doCR(); mPrintf(" Descibed: %s ", grpBuf.group[groupslot].desc); doCR(); getString("new group name", newname, NAMESIZE, FALSE, ECHO, grpBuf.group[groupslot].groupname); getString("new group description", desc, 79, FALSE, ECHO, ""); if (groupexists(newname) != ERROR && stricmp(newname, grpBuf.group[groupslot].groupname) != SAMESTRING) { mPrintf("\n A \'%s\' group already exists.", newname); return; } /* locked group? */ locked = (getYesNo("Lock group from aides", (char)grpBuf.group[groupslot].lockout )); hidden = (getYesNo("Make group hidden", (char)grpBuf.group[groupslot].hidden )); if (groupslot) { autoAdd = (getYesNo("Make group auto-add", (char)grpBuf.group[groupslot].autoAdd)); } if (getYesNo(confirm, 0)) { grpBuf.group[groupslot].lockout = locked; grpBuf.group[groupslot].hidden = hidden; grpBuf.group[groupslot].autoAdd = autoAdd; strcpy(grpBuf.group[groupslot].groupname, newname); if (*desc) { strcpy(grpBuf.group[groupslot].desc, desc); } sprintf(msgBuf->mbtext, "Group %s renamed %s", groupname, newname); trap(msgBuf->mbtext, T_SYSOP); putGroup(); } }