From 536fe6888876cd2728c9621233e9ade8f8dd4da9 Mon Sep 17 00:00:00 2001 From: "Rob Swindell (on ChromeOS)" <rob@synchro.net> Date: Sat, 1 Apr 2023 14:37:09 -0700 Subject: [PATCH] Resolve warnings from GCC 10.2 Include some constification of xsdk functions Added some comments (observed concerns) in TBD about the object[] definition not matching (struct/type and contents) between objects.h and tbd2.c. --- xtrn/dpoker/dpoker.c | 53 ++++----- xtrn/sbj/sbj.c | 47 ++++---- xtrn/sdk/xsdk.c | 272 ++++++++++++++++++++++--------------------- xtrn/sdk/xsdk.h | 32 ++--- xtrn/tbd/objects.h | 126 ++++++++++---------- xtrn/tbd/reroll.c | 4 +- xtrn/tbd/tbd.c | 19 +-- xtrn/tbd/tbd2.c | 159 +++++++++++++------------ 8 files changed, 365 insertions(+), 347 deletions(-) diff --git a/xtrn/dpoker/dpoker.c b/xtrn/dpoker/dpoker.c index 1187b3b09b..a36e423884 100644 --- a/xtrn/dpoker/dpoker.c +++ b/xtrn/dpoker/dpoker.c @@ -50,19 +50,20 @@ char compiler[32]; typedef struct { char value, suit; } card_t; card_t newdeck[52]={ - 2,H, 2,D, 2,C, 2,S, - 3,H, 3,D, 3,C, 3,S, - 4,H, 4,D, 4,C, 4,S, - 5,H, 5,D, 5,C, 5,S, - 6,H, 6,D, 6,C, 6,S, - 7,H, 7,D, 7,C, 7,S, - 8,H, 8,D, 8,C, 8,S, - 9,H, 9,D, 9,C, 9,S, - 10,H,10,D,10,C,10,S, - J,H, J,D, J,C, J,S, - Q,H, Q,D, Q,C, Q,S, - K,H, K,D, K,C, K,S, - A,H, A,D, A,C, A,S }; + { 2,H }, { 2,D }, { 2,C }, { 2,S }, + { 3,H }, { 3,D }, { 3,C }, { 3,S }, + { 4,H }, { 4,D }, { 4,C }, { 4,S }, + { 5,H }, { 5,D }, { 5,C }, { 5,S }, + { 6,H }, { 6,D }, { 6,C }, { 6,S }, + { 7,H }, { 7,D }, { 7,C }, { 7,S }, + { 8,H }, { 8,D }, { 8,C }, { 8,S }, + { 9,H }, { 9,D }, { 9,C }, { 9,S }, + {10,H }, {10,D }, {10,C }, {10,S }, + { J,H }, { J,D }, { J,C }, { J,S }, + { Q,H }, { Q,D }, { Q,C }, { Q,S }, + { K,H }, { K,D }, { K,C }, { K,S }, + { A,H }, { A,D }, { A,C }, { A,S } +}; card_t deck[52], card[52]; card_t hand[MAX_NODES+1][10]; @@ -147,7 +148,7 @@ enum { OPEN, DEAL, BET, DISCARD, BET2, GET_WINNER }; #pragma pack(1) #endif -#ifdef __GNUC__ +#ifdef __GNUC__ #define _PACK __attribute__ ((packed)) #else #define _PACK @@ -205,7 +206,7 @@ int main(int argc, char **argv) printf("\tL = Create daily log of computer vs player " "wins/losses\n"); printf("\tCLEAN = Clean-up player/node data (replaces 'dpclean')\n"); - return(0); + return(0); } } initdata(); @@ -471,7 +472,7 @@ void discard() bprintf("\x1b[6A"); do { strcpy(dishand,handstr(node_num)); if(!symbols) strip_symbols(dishand); - sprintf(str,"\r\n\t\t\t\1b\1h%s - \1b\1h(\1c%s\1b)\1n",dishand, + snprintf(str, sizeof(str), "\r\n\t\t\t\1b\1h%s - \1b\1h(\1c%s\1b)\1n",dishand, ranking(rank)); bprintf("%s\r\n\t\t\t\1b\1h(\1c1\1b) (\1c2\1b) (\1c3\1b) (\1c4\1b) " "(\1c5\1b)\r\n",str); @@ -1031,7 +1032,7 @@ void play_menu() *waitcmd="\1y\1hCommand \1b\1h(\1c\1hL,S,Y,Q,^P,^U,?\1b\1h):\1n ", *dealcmd="\1m\1hDealer \1n\1b\1h(\1c\1hD,L,S,Y,Q,^P,^U,?\1b\1h):\1n "; int warn,tt; - time_t timeout,timeout2,now; + time_t timeout, now; sprintf(fname,"message.%d",node_num); get_game_status(cur_table); @@ -1044,7 +1045,6 @@ void play_menu() else bprintf(waitcmd); /* Show the command prompt */ timeout=time(NULL); /* Set entry time here */ - timeout2=time(NULL); /* for the demo game timer only */ do { now=time(NULL); /* Start the timer here */ @@ -1119,7 +1119,7 @@ void play_menu() get_player(node_num); if (flength(fname)>0) { /* Checks for new player */ bprintf("\r\n"); /* Messages and reads them */ - do { + do { read_player_message(); mswait(100); } while (flength(fname)>0); @@ -1164,7 +1164,7 @@ void play_menu() } if (!cur_node && dealer==node_num) { /* Computer is cur_node */ - if (stage==BET && comp_bet!=current_bet || !current_bet) { + if ((stage==BET && comp_bet!=current_bet) || !current_bet) { bprintf("\r\n"); computer_bet(); timeout=time(NULL); warn=0; bprintf("\r\n"); nodesync(); @@ -1211,9 +1211,7 @@ void play_menu() time_played+=time(NULL)-now; if (time_played>time_allowed) time_played=time_allowed; } - if (timeout2); - - if((now-timeout)>=240 && !warn) /* Warning Beep */ + if((now-timeout)>=240 && !warn) /* Warning Beep */ for(warn=0;warn<5;warn++) { putchar(7); } @@ -1435,7 +1433,8 @@ void dealer_ctrl() declare_winner(); return; /* All but 1 has folded */ } - if (firstbid) firstbid=0; put_game_status(-1); x=0; + if (firstbid) firstbid=0; + put_game_status(-1); x=0; for (num=1;num<=sys_nodes;num++) { if (node[num-1]==WAITING) { get_player(num); @@ -1709,7 +1708,9 @@ void gethandtype(int player) highest_card=hand[player][i].value; if (temphand[0].suit==hand[player][i].suit) x++; for (j=0;j<5;j++) { - if (m==j) j++; if (m1==j) j++; if (m2==j) j++; + if (m==j) j++; + if (m1==j) j++; + if (m2==j) j++; if (temphand[i].value==hand[player][j].value) { same++; if (same==2 && i<5 && m>-1 && m1==-1) { @@ -1907,7 +1908,7 @@ void send_message() do { if (!getstr(str1,45,K_CHAT|K_WRAP)) break; - sprintf(str,"\r\n\1g\1hFrom %s: \1n\1g%s\r\n",user_name + snprintf(str, sizeof(str), "\r\n\1g\1hFrom %s: \1n\1g%s\r\n",user_name ,str1); if (num=='A') { send_all_message(str,0); diff --git a/xtrn/sbj/sbj.c b/xtrn/sbj/sbj.c index f77f94531f..a953cdea01 100644 --- a/xtrn/sbj/sbj.c +++ b/xtrn/sbj/sbj.c @@ -1,7 +1,3 @@ -/* SBJ.C */ - -/* $Id: sbj.c,v 1.14 2003/08/29 21:51:52 rswindell Exp $ */ - /************************/ /* Synchronet Blackjack */ /************************/ @@ -111,19 +107,20 @@ enum { /* values for status bytes */ typedef struct { char value, suit; } card_t; card_t newdeck[52]={ - 2,H, 2,D, 2,C, 2,S, - 3,H, 3,D, 3,C, 3,S, - 4,H, 4,D, 4,C, 4,S, - 5,H, 5,D, 5,C, 5,S, - 6,H, 6,D, 6,C, 6,S, - 7,H, 7,D, 7,C, 7,S, - 8,H, 8,D, 8,C, 8,S, - 9,H, 9,D, 9,C, 9,S, - 10,H,10,D,10,C,10,S, - J,H, J,D, J,C, J,S, - Q,H, Q,D, Q,C, Q,S, - K,H, K,D, K,C, K,S, - A,H, A,D, A,C, A,S }; + { 2,H }, { 2,D }, { 2,C }, { 2,S }, + { 3,H }, { 3,D }, { 3,C }, { 3,S }, + { 4,H }, { 4,D }, { 4,C }, { 4,S }, + { 5,H }, { 5,D }, { 5,C }, { 5,S }, + { 6,H }, { 6,D }, { 6,C }, { 6,S }, + { 7,H }, { 7,D }, { 7,C }, { 7,S }, + { 8,H }, { 8,D }, { 8,C }, { 8,S }, + { 9,H }, { 9,D }, { 9,C }, { 9,S }, + {10,H }, {10,D }, {10,C }, {10,S }, + { J,H }, { J,D }, { J,C }, { J,S }, + { Q,H }, { Q,D }, { Q,C }, { Q,S }, + { K,H }, { K,D }, { K,C }, { K,S }, + { A,H }, { A,D }, { A,C }, { A,S } +}; uchar misc; uchar curplayer; @@ -201,7 +198,7 @@ int my_random(int n) /****************************************************************************/ int main(int argc, char **argv) { - char str[81],compiler[32],*p; + char str[128],compiler[32],*p; int i,file; FILE *stream; @@ -330,7 +327,7 @@ int main(int argc, char **argv) mnelow=CYAN|HIGH; /* Override default inactivity timeout values */ - sec_warn=120; + sec_warn=120; sec_timeout=180; COMPILER_DESC(compiler); @@ -391,8 +388,8 @@ int main(int argc, char **argv) play(); sec_warn=120; sec_timeout=180; - break; - } + break; + } } } @@ -576,7 +573,7 @@ while(1) { max=max_bet; else max=credits/1024L; - sprintf(str,"\r\nBet amount (in kilobytes) or ~Quit [%u]: " + sprintf(str,"\r\nBet amount (in kilobytes) or ~Quit [%lu]: " ,ibet<credits/1024L ? ibet : credits/1024L); chat(); mnemonics(str); @@ -637,7 +634,7 @@ while(1) { bputs(str); sprintf(str,UserWasDealt,user_name,cardstr(card[cur_card-1])); putallnodemsg(str); - + if(lastplayer()) { getcarddat(); dealer[0]=card[cur_card++]; @@ -659,7 +656,7 @@ while(1) { bputs(str); sprintf(str,UserWasDealt,user_name,cardstr(card[cur_card-1])); putallnodemsg(str); - + if(lastplayer()) { getcarddat(); dealer[1]=card[cur_card++]; @@ -1417,7 +1414,7 @@ while(node[node_num-1] && status[node_num-1]==SYNC_P) { /****************************************************************************/ void moduserdat() { - char str[128]; + char str[MAX_PATH + 1]; FILE *stream; sprintf(str,"%sMODUSER.DAT",node_dir); diff --git a/xtrn/sdk/xsdk.c b/xtrn/sdk/xsdk.c index 92783296b4..93df071ad8 100644 --- a/xtrn/sdk/xsdk.c +++ b/xtrn/sdk/xsdk.c @@ -22,7 +22,7 @@ /***************************** Revision History *****************************\ Initial version for use with Synchronet v1a r6 - 1.0� + 1.0� Added bgotoxy() macro Added mnehigh and mnelow vars for control of the mnemonic colors Added sys_nodes and node_num variables to xtrn_sdk.c @@ -184,12 +184,12 @@ Added support for telnet nodes (connection=0xffff) 3.00 Fixed problem with clear screen (form feed) in node messages. - checkline() now exits when the remote user disconnects on 32-bit + checkline() now exits when the remote user disconnects on 32-bit programs. Use atexit() to add cleanup code. 3.01 Eliminated warnings in ctrl_a() when compiled with VC++ 6.0. Added Linux/GCC support (xsdkwrap.c, xsdkwrap.h, and xsdkinet.h) - 3.10 + 3.10 Added COMPILER_DESC and PLATFORM_DESC macros to xsdkwrap.h Added support for no local console (XSDK_MODE_NOCONSOLE) - This is now the default mode when building 32-bit programs @@ -225,7 +225,7 @@ int cbreakh(void) /* ctrl-break handler */ /****************************************************************************/ /* Performs printf() using bbs bputs function */ /****************************************************************************/ -int bprintf(char *fmt, ...) +int bprintf(const char *fmt, ...) { va_list argptr; char sbuf[1024]; @@ -241,7 +241,7 @@ int bprintf(char *fmt, ...) /****************************************************************************/ /* Performs printf() using bbs rputs function */ /****************************************************************************/ -int rprintf(char *fmt, ...) +int rprintf(const char *fmt, ...) { va_list argptr; char sbuf[1024]; @@ -257,7 +257,7 @@ int rprintf(char *fmt, ...) /****************************************************************************/ /* Outputs a NULL terminated string locally and remotely (if applicable) */ /****************************************************************************/ -void bputs(char *str) +void bputs(const char *str) { ulong l=0; @@ -276,7 +276,7 @@ void bputs(char *str) /* Does not process ctrl-a codes (raw output) */ /* Max length of str is 64 kbytes */ /****************************************************************************/ -void rputs(char *str) +void rputs(const char *str) { ulong l=0; @@ -288,7 +288,7 @@ void rputs(char *str) /* Returns the number of characters in 'str' not counting ctrl-ax codes */ /* or the null terminator */ /****************************************************************************/ -int bstrlen(char *str) +int bstrlen(const char *str) { int i=0; @@ -310,7 +310,7 @@ int bstrlen(char *str) /* Outputs the string 'str' centered for an 80 column display */ /* Automatically appends "\r\n" to output */ /****************************************************************************/ -void center(char *str) +void center(const char *str) { int i,j; @@ -338,7 +338,7 @@ void output_thread(void* arg) if(outbufbot==outbuftop) { sem_init(&output_sem,0,0); sem_wait(&output_sem); - continue; + continue; } if(outbuftop>outbufbot) @@ -395,31 +395,31 @@ void outchar(char ch) if(ch==LF) { lncntr++; lbuflen=0; - tos=0; + tos=0; } else if(ch==FF) { if(lncntr>1) { lncntr=0; CRLF; - bpause(); + bpause(); } lncntr=0; lbuflen=0; - tos=1; + tos=1; } else if(ch==BS) { if(lbuflen) - lbuflen--; + lbuflen--; } else { if(!lbuflen) latr=curatr; if(lbuflen>=LINE_BUFSIZE) lbuflen=0; - lbuf[lbuflen++]=ch; + lbuf[lbuflen++]=ch; } if(lncntr==user_rows-1) { lncntr=0; - bpause(); + bpause(); } lastch=ch; } @@ -439,7 +439,8 @@ void flushoutput(void) void bpause(void) { char ch; - uchar tempattrs=curatr,*msg="\1_\1r\1h[Hit a key] "; + uchar tempattrs=curatr; + const char* msg="\1_\1r\1h[Hit a key] "; int i,j; lncntr=0; @@ -458,7 +459,7 @@ void bpause(void) /* Returns 1 for Y or 0 for N */ /* Called from quite a few places */ /****************************************************************************/ -char yesno(char *str) +char yesno(const char *str) { char ch; @@ -470,8 +471,8 @@ char yesno(char *str) return(1); } if(ch=='N' || aborted) { bputs("No\r\n"); - return(0); - } + return(0); + } } } @@ -480,7 +481,7 @@ char yesno(char *str) /* Returns 1 for N or 0 for Y */ /* Called from quite a few places */ /****************************************************************************/ -char noyes(char *str) +char noyes(const char *str) { char ch; @@ -492,8 +493,8 @@ char noyes(char *str) return(1); } if(ch=='Y') { bputs("Yes\r\n"); - return(0); - } + return(0); + } } } @@ -503,7 +504,7 @@ char noyes(char *str) /* If the user doesn't have ANSI, it puts the character following the tilde */ /* in parenthesis. */ /****************************************************************************/ -void mnemonics(char *str) +void mnemonics(const char *str) { long l; @@ -519,10 +520,10 @@ void mnemonics(char *str) l++; if(!(user_misc&ANSI)) outchar(')'); - attr(mnelow); + attr(mnelow); } else - outchar(str[l++]); + outchar(str[l++]); } attr(LIGHTGRAY); } @@ -592,7 +593,7 @@ char inkey(long mode) } } - if(i==0 && cnt) + if(i==0 && cnt) recv(client_socket,&ch,1,0); else #endif @@ -626,7 +627,7 @@ char inkey(long mode) case 0x53: /* Delete */ return(0x7f); /* ctrl-bkspc - del cur char */ } - return(0); } + return(0); } ch=i; } @@ -717,7 +718,7 @@ char inkey(long mode) return(0); } #ifndef __16BIT__ - if(ch==LF) + if(ch==LF) ch=0; /* Ignore LF of Telnet CR/LF sequence */ #endif @@ -756,7 +757,7 @@ char getkey(long mode) if(ch==LF) continue; if(mode&K_UPPER) return(toupper(ch)); - return(ch); + return(ch); } checktimeleft(); @@ -770,7 +771,7 @@ char getkey(long mode) bprintf("\1n\1h\r\n\7\r\nYou only have \1r\1i%u\1n\1h minute%s " "left.\r\n\r\n" ,((ushort)tleft/60)+1,(tleft/60) ? "s" : ""); - RESTORELINE; + RESTORELINE; } } @@ -839,13 +840,13 @@ void checkline(void) /* returned with the high bit set. If the return of this function has the */ /* high bit set (&0x8000), just flip the bit (^0x8000) to get the number. */ /****************************************************************************/ -int getkeys(char *instr,int max) +int getkeys(const char *instr,int max) { char str[256]; uchar ch,n=0; int i=0; - sprintf(str,"%.*s",sizeof(str)-1,instr); + sprintf(str,"%.*s",(int)sizeof(str)-1,instr); strupr(str); while(!aborted) { ch=getkey(K_UPPER); @@ -855,19 +856,19 @@ int getkeys(char *instr,int max) outchar(ch); attr(LIGHTGRAY); CRLF; - return(ch); + return(ch); } if(ch==CR && max) { /* return 0 if no number */ attr(LIGHTGRAY); CRLF; if(n) return(i|0x8000); /* return number plus high bit */ - return(0); + return(0); } if(ch==BS && n) { bputs("\b \b"); i/=10; - n--; + n--; } else if(max && isdigit(ch) && (i*10)+(ch&0xf)<=max && (ch!='0' || n)) { i*=10; @@ -877,9 +878,9 @@ int getkeys(char *instr,int max) if(i*10>max) { attr(LIGHTGRAY); CRLF; - return(i|0x8000); - } - } + return(i|0x8000); + } + } } return(0); } @@ -940,18 +941,18 @@ int getstr(char *strout, size_t maxlen, long mode) { size_t i,l,x,z; /* i=current position, l=length, j=printed chars */ /* x&z=misc */ - uchar ch,str1[256],str2[256],ins=0,atr; + char ch,str1[256],str2[256],ins=0,atr; if(mode&K_LINE && user_misc&ANSI) { attr(LIGHTGRAY|HIGH|(BLUE<<4)); /* white on blue */ for(i=0;i<maxlen;i++) outchar(' '); - bprintf("\x1b[%dD",maxlen); + bprintf("\x1b[%dD",maxlen); } i=l=0; /* i=total number of chars, j=number of printable chars */ if(wordwrap[0]) { strcpy(str1,wordwrap); - wordwrap[0]=0; + wordwrap[0]=0; } else str1[0]=0; if(mode&K_EDIT) @@ -972,16 +973,16 @@ int getstr(char *strout, size_t maxlen, long mode) if(isprint(ch) || ch==0x7f) { for(i=0;i<l;i++) bputs("\b \b"); - i=l=0; + i=l=0; } else { for(i=0;i<l;i++) outchar(BS); rputs(str1); - i=l; + i=l; } if(ch!=' ' && ch!=TAB) - ungetkey(ch); + ungetkey(ch); } while((ch=getkey(mode|K_GETSTR))!=CR && !aborted) { @@ -997,14 +998,14 @@ int getstr(char *strout, size_t maxlen, long mode) rprintf("%.*s",l-i,str1+i); rprintf("\x1b[%dD",l-i); if(i==maxlen-1) - ins=0; + ins=0; } outchar(str1[i++]=1); break; case TERM_KEY_HOME: /* Ctrl-B Beginning of Line */ if(user_misc&ANSI && i) { bprintf("\x1b[%dD",i); - i=0; + i=0; } break; case 4: /* Ctrl-D Delete word right */ @@ -1012,21 +1013,21 @@ int getstr(char *strout, size_t maxlen, long mode) x=i; while(x<l && str1[x]!=' ') { outchar(' '); - x++; + x++; } while(x<l && str1[x]==' ') { outchar(' '); - x++; + x++; } bprintf("\x1b[%dD",x-i); /* move cursor back */ z=i; while(z<l-(x-i)) { /* move chars in string */ outchar(str1[z]=str1[z+(x-i)]); - z++; + z++; } while(z<l) { /* write over extra chars */ outchar(' '); - z++; + z++; } bprintf("\x1b[%dD",z-i); l-=x-i; /* l=new length */ @@ -1035,13 +1036,13 @@ int getstr(char *strout, size_t maxlen, long mode) case TERM_KEY_END: /* Ctrl-E End of line */ if(user_misc&ANSI && i<l) { bprintf("\x1b[%dC",l-i); /* move cursor right one */ - i=l; + i=l; } break; case 6: /* Ctrl-F move cursor forewards */ if(i<l && (user_misc&ANSI)) { bputs("\x1b[C"); /* move cursor right one */ - i++; + i++; } break; case 7: @@ -1053,11 +1054,11 @@ int getstr(char *strout, size_t maxlen, long mode) for(x=l;x>i;x--) str1[x]=str1[x-1]; if(i==maxlen-1) - ins=0; + ins=0; } if(i<maxlen) { str1[i++]=7; - outchar(7); + outchar(7); } break; case 14: /* Ctrl-N Next word */ @@ -1067,7 +1068,7 @@ int getstr(char *strout, size_t maxlen, long mode) i++; while(str1[i]==' ' && i<l) i++; - bprintf("\x1b[%dC",i-x); + bprintf("\x1b[%dC",i-x); } break; case 0x1c: /* Ctrl-\ Previous word */ @@ -1077,7 +1078,7 @@ int getstr(char *strout, size_t maxlen, long mode) i--; while(str1[i-1]!=' ' && i) i--; - bprintf("\x1b[%dD",x-i); + bprintf("\x1b[%dD",x-i); } break; case 18: /* Ctrl-R Redraw Line */ @@ -1091,10 +1092,10 @@ int getstr(char *strout, size_t maxlen, long mode) for(x=l;x>i;x--) str1[x]=str1[x-1]; if(i==maxlen-1) - ins=0; + ins=0; } str1[i++]=' '; - outchar(' '); + outchar(' '); } while(i<maxlen && i%TABSIZE) { if(ins) { @@ -1103,10 +1104,10 @@ int getstr(char *strout, size_t maxlen, long mode) for(x=l;x>i;x--) str1[x]=str1[x-1]; if(i==maxlen-1) - ins=0; + ins=0; } str1[i++]=' '; - outchar(' '); + outchar(' '); } if(ins) redrwstr(str1,i,l,0); @@ -1121,10 +1122,10 @@ int getstr(char *strout, size_t maxlen, long mode) z=i; while(z<l) { /* move the characters in the line */ outchar(str1[z]=str1[z+1]); - z++; + z++; } outchar(' '); /* write over the last char */ - bprintf("\x1b[%dD",(l-i)+1); + bprintf("\x1b[%dD",(l-i)+1); } else bputs("\b \b"); @@ -1145,7 +1146,7 @@ int getstr(char *strout, size_t maxlen, long mode) bputs("\b"); bputs(strout); if(mode&K_LINE) - attr(LIGHTGRAY); + attr(LIGHTGRAY); } CRLF; return(l); @@ -1154,20 +1155,20 @@ int getstr(char *strout, size_t maxlen, long mode) x=i; /* x=original offset */ while(i && str1[i-1]==' ') { outchar(BS); - i--; + i--; } while(i && str1[i-1]!=' ') { outchar(BS); - i--; + i--; } z=i; /* i=z=new offset */ while(z<l-(x-i)) { /* move chars in string */ outchar(str1[z]=str1[z+(x-i)]); - z++; + z++; } while(z<l) { /* write over extra chars */ outchar(' '); - z++; + z++; } bprintf("\x1b[%dD",z-i); /* back to new x corridnant */ l-=x-i; /* l=new length */ @@ -1176,30 +1177,30 @@ int getstr(char *strout, size_t maxlen, long mode) while(i && str1[i-1]==' ') { i--; l--; - bputs("\b \b"); + bputs("\b \b"); } while(i && str1[i-1]!=' ') { i--; l--; - bputs("\b \b"); - } + bputs("\b \b"); + } } break; case 24: /* Ctrl-X Delete entire line */ while(i<l) { outchar(' '); - i++; + i++; } while(l) { l--; - bputs("\b \b"); + bputs("\b \b"); } i=0; break; case 25: /* Ctrl-Y Delete to end of line */ if(user_misc&ANSI) { bputs("\x1b[s\x1b[K\x1b[u"); - l=i; + l=i; } break; case 22: /* Ctrl-V Toggles Insert/Overwrite */ @@ -1207,7 +1208,7 @@ int getstr(char *strout, size_t maxlen, long mode) break; if(ins) { ins=0; - redrwstr(str1,i,l,0); + redrwstr(str1,i,l,0); } else if(i<l) { ins=1; @@ -1222,7 +1223,7 @@ int getstr(char *strout, size_t maxlen, long mode) case 0x1d: /* Ctrl-] Reverse Cursor Movement */ if(i && (user_misc&ANSI)) { bputs("\x1b[D"); /* move cursor left one */ - i--; + i--; } break; case 0x7f: /* Ctrl-BkSpc (DEL) Delete current char */ @@ -1238,7 +1239,7 @@ int getstr(char *strout, size_t maxlen, long mode) z=i; while(z<l) { /* move the characters in the line */ outchar(str1[z]=str1[z+1]); - z++; + z++; } outchar(' '); /* write over the last char */ bprintf("\x1b[%dD",(l-i)+1); @@ -1248,29 +1249,29 @@ int getstr(char *strout, size_t maxlen, long mode) break; if((ch=getkey(0x8000))!='[') { ungetkey(ch); - break; + break; } if((ch=getkey(0x8000))=='C') { if(i<l) { bputs("\x1b[C"); /* move cursor right one */ - i++; - } + i++; + } } else if(ch=='D') { if(i) { bputs("\x1b[D"); /* move cursor left one */ - i--; - } + i--; + } } else { while(isdigit(ch) || ch==';' || isalpha(ch)) { if(isalpha(ch)) { ch=getkey(0); - break; + break; } - ch=getkey(0); + ch=getkey(0); } - ungetkey(ch); + ungetkey(ch); } break; default: @@ -1281,7 +1282,7 @@ int getstr(char *strout, size_t maxlen, long mode) if(stripattr(strout)) redrwstr(strout,i,l,K_MSG); CRLF; - return(i); + return(i); } x=i-1; z=1; @@ -1294,12 +1295,12 @@ int getstr(char *strout, size_t maxlen, long mode) if(stripattr(strout)) redrwstr(strout,i,l,K_MSG); CRLF; - return(i); + return(i); } wordwrap[z]=0; while(z--) { i--; - bputs("\b \b"); + bputs("\b \b"); } strrev(wordwrap); str1[x]=0; @@ -1307,15 +1308,16 @@ int getstr(char *strout, size_t maxlen, long mode) if(stripattr(strout)) redrwstr(strout,i,x,mode); CRLF; - return(x); + return(x); } if(i<maxlen && ch>=' ') { - if(mode&K_UPRLWR) + if(mode&K_UPRLWR) { if(!i || (i && (str1[i-1]==' ' || str1[i-1]=='-' || str1[i-1]=='.' || str1[i-1]=='_'))) ch=toupper(ch); else ch=tolower(ch); + } if(ins) { if(l<maxlen) /* l<maxlen */ l++; @@ -1325,17 +1327,17 @@ int getstr(char *strout, size_t maxlen, long mode) rprintf("\x1b[%dD",l-i); if(i==maxlen-1) { bputs(" \b\b"); - ins=0; - } + ins=0; + } } str1[i++]=ch; - outchar(ch); - } + outchar(ch); + } } /* switch */ if(i>l) l=i; if(mode&K_CHAT && !l) - return(0); + return(0); } if(i>l) l=i; @@ -1343,7 +1345,7 @@ int getstr(char *strout, size_t maxlen, long mode) if(!aborted) { strcpy(strout,str1); if(stripattr(strout) || ins) - redrwstr(strout,i,l,K_MSG); + redrwstr(strout,i,l,K_MSG); } else l=0; @@ -1351,7 +1353,7 @@ int getstr(char *strout, size_t maxlen, long mode) if(!(mode&K_NOCRLF)) { outchar(CR); if(!(mode&K_MSG && aborted)) - outchar(LF); + outchar(LF); } return(l); } @@ -1359,7 +1361,7 @@ int getstr(char *strout, size_t maxlen, long mode) /****************************************************************************/ /* Redraws str using i as current cursor position and l as length */ /****************************************************************************/ -void redrwstr(char *strin, int i, int l, long mode) +void redrwstr(const char *strin, int i, int l, long mode) { char str[256],c; @@ -1374,17 +1376,17 @@ void redrwstr(char *strin, int i, int l, long mode) if(user_misc&ANSI) { bputs("\x1b[K"); if(i<l) - bprintf("\x1b[%dD",l-i); + bprintf("\x1b[%dD",l-i); } else { while(c<79) { /* clear to end of line */ outchar(' '); - c++; + c++; } while(c>l) { /* back space to end of string */ outchar(BS); - c--; - } + c--; + } } } @@ -1394,8 +1396,8 @@ void redrwstr(char *strin, int i, int l, long mode) /****************************************************************************/ char stripattr(char *strin) { - uchar str[81]; - uchar a,c,d,e; + char str[81]; + size_t a,c,d,e; e=strlen(strin); for(a=c=d=0;c<e;c++) { @@ -1429,10 +1431,10 @@ char stripattr(char *strin) break; default: c++; - continue; - } + continue; + } } - str[d++]=strin[c]; + str[d++]=strin[c]; } str[d]=0; strcpy(strin,str); @@ -1540,7 +1542,7 @@ void cls(void) if(user_misc&ANSI) bputs("\x1b[2J\x1b[H"); /* clear screen, home cursor */ - else + else outchar(FF); tos=1; lncntr=0; @@ -1765,7 +1767,7 @@ void initdata(void) /* Sets node_dir to node directory environment variable defined by synchronet. */ if(node_dir[0]==0 && (p=getenv("SBBSNODE"))!=NULL) - sprintf(node_dir,"%.*s",sizeof(node_dir)-1,p); + sprintf(node_dir,"%.*s",(int)sizeof(node_dir)-1,p); sprintf(str,"%sXTRN.DAT",node_dir); if((stream=fopen(str,"rt"))==NULL) { @@ -1787,7 +1789,7 @@ void initdata(void) fgets(str,81,stream); /* ctrl dir */ str[50]=0; if(str[0]=='.') - sprintf(ctrl_dir,"%s%s",node_dir,str); + snprintf(ctrl_dir, sizeof(ctrl_dir), "%s%s",node_dir,str); else strcpy(ctrl_dir,str); truncsp(ctrl_dir); @@ -1797,7 +1799,7 @@ void initdata(void) fgets(str,81,stream); /* data dir */ if(str[0]=='.') - sprintf(data_dir,"%s%s",node_dir,str); + snprintf(data_dir, sizeof(data_dir), "%s%s",node_dir,str); else sprintf(data_dir,"%.40s",str); truncsp(data_dir); @@ -1874,13 +1876,13 @@ void initdata(void) else total_xtrns=atoi(str); if(total_xtrns && (xtrn=(char **)malloc(sizeof(char *)*total_xtrns))==NULL) { - printf("Allocation error 1: %u\r\n",sizeof(char *)*total_xtrns); + printf("Allocation error 1: %u\r\n",(unsigned int)(sizeof(char *)*total_xtrns)); exit(1); } for(i=0;i<(int)total_xtrns;i++) { fgets(str,81,stream); truncsp(str); if((xtrn[i]=(char *)malloc(strlen(str)+1))==NULL) { - printf("Allocation error 2 (%u): %u\r\n",i,strlen(str)+1); + printf("Allocation error 2 (%u): %u\r\n",i,(unsigned int)strlen(str)+1); exit(1); } strcpy(xtrn[i],str); } fgets(str,81,stream); /* user's main flags */ @@ -1910,7 +1912,7 @@ void initdata(void) fgets(str,81,stream); sprintf(user_flags4,"%.26s",str); if(fgets(str,81,stream)) /* Time-slice API type */ -#ifdef __16BIT__ +#ifdef __16BIT__ mswtyp=ahtoul(str); #else ; @@ -1926,10 +1928,10 @@ void initdata(void) str[0]=0; fgets(str,81,stream); /* exec dir */ if(!str[0]) - sprintf(exec_dir,"%s../exec/",ctrl_dir); + snprintf(exec_dir, sizeof(exec_dir), "%s../exec/",ctrl_dir); else { if(str[0]=='.') - sprintf(exec_dir,"%s%s",node_dir,str); + snprintf(exec_dir, sizeof(exec_dir), "%s%s",node_dir,str); else sprintf(exec_dir,"%.50s",str); } truncsp(exec_dir); @@ -1940,10 +1942,10 @@ void initdata(void) str[0]=0; fgets(str,81,stream); /* text dir */ if(!str[0]) - sprintf(text_dir,"%s../text/",ctrl_dir); + snprintf(text_dir, sizeof(text_dir), "%s../text/",ctrl_dir); else { if(str[0]=='.') - sprintf(text_dir,"%s%s",node_dir,str); + snprintf(text_dir, sizeof(text_dir), "%s%s",node_dir,str); else sprintf(text_dir,"%.50s",str); } truncsp(text_dir); @@ -1954,10 +1956,10 @@ void initdata(void) str[0]=0; fgets(str,81,stream); /* temp dir */ if(!str[0]) - sprintf(temp_dir,"%stemp/",node_dir); + snprintf(temp_dir, sizeof(temp_dir), "%stemp/",node_dir); else { if(str[0]!=BACKSLASH && str[1]!=':') - sprintf(temp_dir,"%s%s",node_dir,str); + snprintf(temp_dir, sizeof(temp_dir), "%s%s",node_dir,str); else sprintf(temp_dir,"%.50s",str); } truncsp(temp_dir); @@ -2010,12 +2012,12 @@ void initdata(void) if(fexist(str)) { if((stream=fopen(str,"rt"))==NULL) { printf("Can't open %s\n",str); - exit(1); + exit(1); } fgets(tmp,81,stream); /* so get MSR address from file */ msr=(uint *)atol(tmp); fclose(stream); - remove(str); + remove(str); } starttime=time(NULL); /* initialize start time stamp */ @@ -2033,13 +2035,13 @@ void initdata(void) sprintf(str,"%s%s",ctrl_dir,"node.dab"); if((nodefile=sopen(str,O_BINARY|O_RDWR,SH_DENYNO,S_IREAD|S_IWRITE))==-1) { printf("\r\n\7Error opening %s\r\n",str); - exit(1); + exit(1); } sprintf(str,"%suser/name.dat",data_dir); if((i=nopen(str,O_RDONLY))==-1) { printf("\r\n\7Error opening %s\r\n",str); - exit(1); + exit(1); } memset(str,0,30); read(i,str,26); @@ -2115,8 +2117,8 @@ void backslash(char *str) i=strlen(str); if(i && str[i-1]!='\\' && str[i-1]!='/') { - str[i]=BACKSLASH; - str[i+1]=0; + str[i]=BACKSLASH; + str[i+1]=0; } } #endif /* USE_XPDEV */ @@ -2138,7 +2140,7 @@ void checktimeleft(void) /* Prints a file remotely and locally, interpreting ^A sequences. */ /* 'str' is the path of the file to print */ /****************************************************************************/ -void printfile(char *str) +void printfile(const char *str) { char *buf; int file; @@ -2178,7 +2180,7 @@ char *xsdk_username(uint usernumber) if(!usernumber) { bputs("\7username: called with zero usernumber\r\n"); return(name); } - sprintf(str,"%suser/name.dat",data_dir); + snprintf(str, sizeof(str), "%suser/name.dat",data_dir); if((file=nopen(str,O_RDONLY))==-1) { bprintf("\7username: couldn't open %s\r\n",str); return(name); } @@ -2201,7 +2203,7 @@ char *xsdk_username(uint usernumber) /* Returns the number of the user 'username' from the NAME.DAT file. */ /* If the username is not found, the function returns 0. */ /****************************************************************************/ -uint usernumber(char *username) +uint usernumber(const char *username) { char str[128]; int i,file; @@ -2209,7 +2211,7 @@ uint usernumber(char *username) if(!data_dir[0]) return(0); - sprintf(str,"%suser/name.dat",data_dir); + snprintf(str, sizeof(str), "%suser/name.dat",data_dir); if((file=nopen(str,O_RDONLY))==-1 || (stream=fdopen(file,"rb"))==NULL) { if(file!=-1) close(file); @@ -2251,7 +2253,7 @@ char *ultoac(ulong l, char *string) /****************************************************************************/ /* Converts an ASCII Hex string into a ulong */ /****************************************************************************/ -ulong ahtoul(char *str) +ulong ahtoul(const char *str) { ulong l,val=0; @@ -2280,7 +2282,7 @@ void xsdk_getnodedat(int number, node_t *node, char lockit) continue; } if(read(nodefile,node,sizeof(node_t))==sizeof(node_t)) break; - count++; + count++; mswait(10); } if(count==LOOP_NODEDAB) @@ -2301,7 +2303,7 @@ void xsdk_putnodedat(int number, node_t node) if(write(nodefile,&node,sizeof(node_t))!=sizeof(node_t)) { unlock(nodefile,(long)number*sizeof(node_t),sizeof(node_t)); bprintf("\7Error %d writing node.dab for node %u\r\n", errno, number+1); - return; + return; } unlock(nodefile,(long)number*sizeof(node_t),sizeof(node_t)); } @@ -2580,7 +2582,7 @@ void xsdk_getsmsg(int usernumber) /****************************************************************************/ /* Creates a short message for 'usernumber' than contains 'strin' */ /****************************************************************************/ -void xsdk_putsmsg(int usernumber, char *strin) +void xsdk_putsmsg(int usernumber, const char *strin) { char str[256]; int file,i; @@ -2651,7 +2653,7 @@ void xsdk_getnmsg(void) /****************************************************************************/ /* Creates a short message for node 'num' than contains 'strin' */ /****************************************************************************/ -void xsdk_putnmsg(int num, char *strin) +void xsdk_putnmsg(int num, const char *strin) { char str[256]; int file,i; diff --git a/xtrn/sdk/xsdk.h b/xtrn/sdk/xsdk.h index feee866f6f..136f2a8ed6 100644 --- a/xtrn/sdk/xsdk.h +++ b/xtrn/sdk/xsdk.h @@ -93,25 +93,25 @@ void get_term(void); /* BBS Print String - Displays a string locally and remotely (with Ctrl-A codes) */ -void bputs(char *str); +void bputs(const char *str); /* Raw Print String - Oututs a string locally and remotely (verbatim) */ -void rputs(char *str); +void rputs(const char *str); /* BBS Print Formatted - Displays a formatted string locally and remotely (with Ctrl-A codes) - printf() equivalent */ -int bprintf(char *fmt, ...); +int bprintf(const char *fmt, ...); /* Raw Print Formated - Displays a formatted string locally and remotely (verbatim) - printf() equivalent */ -int rprintf(char *fmt, ...); +int rprintf(const char *fmt, ...); /* BBS String Length - Returns length of string, excluding Ctrl-A codes */ -int bstrlen(char *str); +int bstrlen(const char *str); /* Output character - Displays a single character */ @@ -121,7 +121,7 @@ void outchar(char ch); - Display a string expanding ~letter combinations to command keys - Automatically colorizes mnemonic letters or places them in parenthesis for non-ANSI users */ -void mnemonics(char *str); +void mnemonics(const char *str); /* Pause prompt - Displays [Hit a key] and waits for the user to hit a key */ @@ -132,13 +132,13 @@ void bpause(void); 'Y', 'N' or enter - Returns 1 if the user hit 'Y' or enter - Automatic colorization */ -char yesno(char *str); +char yesno(const char *str); /* No/yes Question - Displays a string with (y/N) ? appended and waits for the user to hit 'Y', 'N' or enter - Returns 1 if the user hit 'N' or enter */ -char noyes(char *str); +char noyes(const char *str); /* Inbound Keystroke - If the local or remote user has struck a key, this function returns the @@ -162,7 +162,7 @@ char getkey(long mode); followed by CRLF - If the user entered a number, the number is ORed with 0x8000 and returned you must XOR (or not) this bit to get the correct number */ -int getkeys(char *str, int max); +int getkeys(const char *str, int max); /* Get a Number - Waits for the user to enter a number from 0 to max, 'Q' or ENTER @@ -212,7 +212,7 @@ void checktimeleft(void); /* Print File - Displays contents of file (expanding Ctrl-A characters if appropriate) */ -void printfile(char *str); +void printfile(const char *str); /* Get String - Waits for the user to enter a string @@ -222,7 +222,7 @@ int getstr(char *str, size_t maxlen, long mode); /* Redraw String - Redisplays a string, mainly called by getstr() */ -void redrwstr(char *strin, int i, int l, long mode); +void redrwstr(const char *strin, int i, int l, long mode); /* Strip Invalid Ctrl-A codes */ char stripattr(char *strin); @@ -232,13 +232,13 @@ char *xsdk_username(uint usernumber); #define username(x) xsdk_username(x) /* Returns the number of the user name passed */ -uint usernumber(char *username); +uint usernumber(const char *username); /* Convert unsigned long to an ASCII string with commas */ char *ultoac(ulong l, char *string); /* Convert an ASCII string of hex digits into an unsigned long */ -ulong ahtoul(char *str); +ulong ahtoul(const char *str); /* Display status of node */ void xsdk_printnodedat(int number, node_t node); @@ -256,7 +256,7 @@ void xsdk_getnodedat(int number, node_t *node, char lockit); #define getnodedat(a,b,c) xsdk_getnodedat(a,b,c) /* Writes a short message (telegram) for specified user number */ -void xsdk_putsmsg(int usernumber, char *strin); +void xsdk_putsmsg(int usernumber, const char *strin); #define putsmsg(a,b) xsdk_putsmsg(a,b) /* Reads and displays short message for specified user number */ @@ -264,7 +264,7 @@ void xsdk_getsmsg(int usernumber); #define getsmsg(a) xsdk_getsmsg(a) /* Writes a node message for specified node */ -void xsdk_putnmsg(int num, char *strin); +void xsdk_putnmsg(int num, const char *strin); #define putnmsg(a,b) xsdk_putnmsg(a,b) /* Reads and displays node message for current node */ @@ -285,7 +285,7 @@ int isconnected(void); void checkline(void); /* Display a line (with ctrl-A codes) centered on the screen */ -void center(char *str); +void center(const char *str); #ifdef _MSC_VER int lock(int file, long offset, long size); diff --git a/xtrn/tbd/objects.h b/xtrn/tbd/objects.h index 192f943421..f4e70d2e96 100644 --- a/xtrn/tbd/objects.h +++ b/xtrn/tbd/objects.h @@ -19,69 +19,69 @@ typedef struct { char type,color,symbol,name[50]; - int value,misc; + int value,misc; // NOTE (TODO): these members are short ints in tbd2.c } object_t; object_t object[62]={ - 0,0,' '," ",0,0, - 1,(BLUE),'',"Dagger",0,4, - 1,(LIGHTBLUE),'',"Long Dagger",1250,5, /* is the damage */ - 1,(LIGHTGREEN),'',"Short Sword",2500,6, /* that they do */ - 1,(LIGHTCYAN),'',"Long Sword",3740,7, - 1,(LIGHTRED),'',"Broad Sword",4360,8, - 1,(LIGHTMAGENTA),'',"Bastard Sword",4680,9, - 1,(YELLOW),'',"2-Handed Sword",4840,10, - 2,(LIGHTBLUE),'�',"Leather Armor",1250,1, /* Misc for Armor */ - 2,(LIGHTGREEN),'�',"Studded Armor",2500,2, /* is their A.C. */ - 2,(LIGHTCYAN),'�',"Scale Armor",3740,3, - 2,(LIGHTRED),'�',"Chain Armor",4360,4, - 2,(LIGHTMAGENTA),'�',"Banded Armor",4680,5, - 2,(YELLOW),'�',"Plate Armor",4840,6, - 3,(YELLOW),'$',"",0,0, - 4,(LIGHTBLUE),'�',"Warp 2 Other Scroll",100,1, - 4,(LIGHTBLUE),'�',"Invisibilty Potion",2500,2, /* 30 seconds */ - 4,(LIGHTGREEN),'�',"Healing Potion",500,3, /* 1-5 points */ - 4,(LIGHTGREEN),'�',"Scroll of Xtra Heal",1000,4, /* 2-10 points */ - 4,(LIGHTMAGENTA),'�',"Mystery Scroll",200,7, - 4,(LIGHTMAGENTA),'�',"Mystery Potion",200,8, - 4,(LIGHTRED),'�', "Ring of Resurrect",2500,0, - 4,(LIGHTCYAN),'�',"Potion of Full Heal",2500,5, - 4,(YELLOW),'�',"Potion of Strength",1500,6, - 4,(BLINK|YELLOW),'',"Magical Key",0,0, - 4,(BLINK|LIGHTRED),'�',"Staff of Power",0,0, - 4,(WHITE),'@',"Magical Compass",0,0, - 4,(BROWN),'F',"Food",0,0, - 5,(YELLOW),'�',"Stairs Going Up (+ to climb up)",0,0, - 5,(LIGHTGREEN),'�',"Stairs Going Down (+ to climb down)",0,1, - 6,(LIGHTCYAN),'�',"Weapons Shop Shopkeeper",0,1, - 6,(LIGHTGREEN),'�',"Armor Shop Shopkeeper",0,2, - 6,(LIGHTRED),'�',"Specialty Store Shopkeeper",0,3, - 7,(LIGHTBLUE),'�',"a Giant Caterpillar",1,1, /* Gold first - */ - 7,(LIGHTGREEN),'�',"a Frag",1,1, /* then level */ - 7,(BROWN),'�',"a Giant Snail",1,2, - 7,(LIGHTRED),'�',"a Deadly Crab",2,2, - 7,(LIGHTCYAN),'�',"a Rattlesnake",2,3, - 7,(LIGHTBLUE),'�',"a Giant",3,3, - 7,(YELLOW),'�',"a Brainsucker",3,4, - 7,(LIGHTMAGENTA),'�',"a Bonecrusher",4,4, - 7,(BLUE),'�',"a Thraxion Stabber",4,5, - 7,(GREEN),'�',"a Conehead",5,5, - 7,(RED),'�',"a Snubber",5,6, - 7,(MAGENTA),'�',"a Little Bojay",6,6, - 7,(LIGHTMAGENTA),'�',"a Big Bojay",6,7, - 7,(BLUE),'�',"a Little Flerp",7,7, - 7,(LIGHTBLUE),'�',"a Big Flerp",7,8, - 7,(LIGHTRED),'�',"a Neck Puller",8,8, - 7,(LIGHTCYAN),'�',"an Inhaler",8,9, - 7,(YELLOW),'�',"a Hunchback",9,9, - 7,(GREEN),'�',"a Creeping Moss",9,10, - 7,(YELLOW),'�',"a Killer Hornet",10,10, - 7,(WHITE),'�',"a Zombie",10,10, - 7,(LIGHTBLUE),'�',"a Killer Mantis",0,15, - 7,(LIGHTRED),'�',"The Beast",0,20, - 8,(GREEN),'',"Tree",0,0, - 8,(YELLOW),'�',"Quicksand",0,0, - 8,(MAGENTA),'',"Pillar",0,0, - 8,(WHITE),'�',"Pillar",0,0, - 8,(BLUE),'�',"Water",0,0, - 8,(WHITE),'�',"Rock",0,0 + { 0,0,' '," ",0,0 }, + { 1,(BLUE),'',"Dagger",0,4 }, + { 1,(LIGHTBLUE),'',"Long Dagger",1250,5 }, /* is the damage */ + { 1,(LIGHTGREEN),'',"Short Sword",2500,6 }, /* that they do */ + { 1,(LIGHTCYAN),'',"Long Sword",3740,7 }, + { 1,(LIGHTRED),'',"Broad Sword",4360,8 }, + { 1,(LIGHTMAGENTA),'',"Bastard Sword",4680,9 }, + { 1,(YELLOW),'',"2-Handed Sword",4840,10 }, + { 2,(LIGHTBLUE),'�',"Leather Armor",1250,1 }, /* Misc for Armor */ + { 2,(LIGHTGREEN),'�',"Studded Armor",2500,2 }, /* is their A.C. */ + { 2,(LIGHTCYAN),'�',"Scale Armor",3740,3 }, + { 2,(LIGHTRED),'�',"Chain Armor",4360,4 }, + { 2,(LIGHTMAGENTA),'�',"Banded Armor",4680,5 }, + { 2,(YELLOW),'�',"Plate Armor",4840,6 }, + { 3,(YELLOW),'$',"",0,0 }, + { 4,(LIGHTBLUE),'�',"Warp 2 Other Scroll",100,1 }, + { 4,(LIGHTBLUE),'�',"Invisibilty Potion",2500,2 }, /* 30 seconds */ + { 4,(LIGHTGREEN),'�',"Healing Potion",500,3 }, /* 1-5 points */ + { 4,(LIGHTGREEN),'�',"Scroll of Xtra Heal",1000,4 }, /* 2-10 points */ + { 4,(LIGHTMAGENTA),'�',"Mystery Scroll",200,7 }, + { 4,(LIGHTMAGENTA),'�',"Mystery Potion",200,8 }, + { 4,(LIGHTRED),'�', "Ring of Resurrect",2500,0 }, + { 4,(LIGHTCYAN),'�',"Potion of Full Heal",2500,5 }, + { 4,(YELLOW),'�',"Potion of Strength",1500,6 }, + { 4,(BLINK|YELLOW),'',"Magical Key",0,0 }, + { 4,(BLINK|LIGHTRED),'�',"Staff of Power",0,0 }, + { 4,(WHITE),'@',"Magical Compass",0,0 }, + { 4,(BROWN),'F',"Food",0,0 }, + { 5,(YELLOW),'�',"Stairs Going Up (+ to climb up)",0,0 }, + { 5,(LIGHTGREEN),'�',"Stairs Going Down (+ to climb down)",0,1 }, + { 6,(LIGHTCYAN),'�',"Weapons Shop Shopkeeper",0,1 }, + { 6,(LIGHTGREEN),'�',"Armor Shop Shopkeeper",0,2 }, + { 6,(LIGHTRED),'�',"Specialty Store Shopkeeper",0,3 }, + { 7,(LIGHTBLUE),'�',"a Giant Caterpillar",1,1 }, /* Gold first - */ + { 7,(LIGHTGREEN),'�',"a Frag",1,1 }, /* then level */ + { 7,(BROWN),'�',"a Giant Snail",1,2 }, + { 7,(LIGHTRED),'�',"a Deadly Crab",2,2 }, + { 7,(LIGHTCYAN),'�',"a Rattlesnake",2,3 }, + { 7,(LIGHTBLUE),'�',"a Giant",3,3 }, + { 7,(YELLOW),'�',"a Brainsucker",3,4 }, + { 7,(LIGHTMAGENTA),'�',"a Bonecrusher",4,4 }, + { 7,(BLUE),'�',"a Thraxion Stabber",4,5 }, + { 7,(GREEN),'�',"a Conehead",5,5 }, + { 7,(RED),'�',"a Snubber",5,6 }, + { 7,(MAGENTA),'�',"a Little Bojay",6,6 }, + { 7,(LIGHTMAGENTA),'�',"a Big Bojay",6,7 }, + { 7,(BLUE),'�',"a Little Flerp",7,7 }, + { 7,(LIGHTBLUE),'�',"a Big Flerp",7,8 }, + { 7,(LIGHTRED),'�',"a Neck Puller",8,8 }, + { 7,(LIGHTCYAN),'�',"an Inhaler",8,9 }, + { 7,(YELLOW),'�',"a Hunchback",9,9 }, + { 7,(GREEN),'�',"a Creeping Moss",9,10 }, + { 7,(YELLOW),'�',"a Killer Hornet",10,10 }, + { 7,(WHITE),'�',"a Zombie",10,10 }, + { 7,(LIGHTBLUE),'�',"a Killer Mantis",0,15 }, + { 7,(LIGHTRED),'�',"The Beast",0,20 }, + { 8,(GREEN),'',"Tree",0,0 }, + { 8,(YELLOW),'�',"Quicksand",0,0 }, + { 8,(MAGENTA),'',"Pillar",0,0 }, + { 8,(WHITE),'�',"Pillar",0,0 }, + { 8,(BLUE),'�',"Water",0,0 }, + { 8,(WHITE),'�',"Rock",0,0 } }; diff --git a/xtrn/tbd/reroll.c b/xtrn/tbd/reroll.c index a37c8c69fb..41404fbde3 100644 --- a/xtrn/tbd/reroll.c +++ b/xtrn/tbd/reroll.c @@ -64,7 +64,7 @@ int main(int argc, char **argv) { FILE *stream; - char door=0,room[SQUARE][SQUARE],str[128]; + char door=0,room[SQUARE][SQUARE]; unsigned char ch,val; int file,v=0,w=0,x=0,y=0,z=1,weapons[10],weapons2[10],armor[10],armor2[10], magic[10],magic2[10],num_monster,num_gold,fountain[10],stairs,staff, @@ -325,7 +325,7 @@ for (w=0;w<LEVELS;w++) { if(object[ch].type==STAIRS) { if(w<5 && w>1) ch=NUM_MONSTER+rand()%7; else if(w==1 || w==5) ch=NUM_MONSTER+7+rand()%7; - else ch=NUM_MONSTER+14+rand()%8; + else ch=NUM_MONSTER+14+rand()%8; } if(object[ch].type==GOLD) { ++num_gold; diff --git a/xtrn/tbd/tbd.c b/xtrn/tbd/tbd.c index d73e787887..7fb8916316 100644 --- a/xtrn/tbd/tbd.c +++ b/xtrn/tbd/tbd.c @@ -88,7 +88,7 @@ int main(int argc, char **argv) if (!strchr(argv[x],'/')) { strcpy(node_dir,argv[x]); backslash(node_dir); } - + if(strstr(strupr(argv[x]),"/COST=")) { p=strchr(argv[x],'='); if(p!=NULL) cost_per_min=atoi(p+1); } @@ -122,7 +122,7 @@ int main(int argc, char **argv) return(0); } if((file=nopen("tbd.mnt",O_RDWR))==-1) { - cls(); + cls(); bprintf("\r\nPLEASE WAIT: Daily maintenance is running."); for(x=0;x<(SQUARE/2);x++) { mswait(1000); bprintf("."); } } else { @@ -728,7 +728,8 @@ void movement(int sx,int sy,int sz,int sgx,int sgy) } if(invisible) write_movement(32,x,y,z,gx,gy); else write_movement(tpic,x,y,z,gx,gy); - if(user.mapx!=x) user.mapx=x; if(user.mapy!=y) user.mapy=y; + if(user.mapx!=x) user.mapx=x; + if(user.mapy!=y) user.mapy=y; if(in_shop && weapon_ready) { /* put weapon away if drawn */ status_message(0,"\1r\1hAll weapons must be put away while you" " are within shops!"); @@ -965,7 +966,7 @@ void movement(int sx,int sy,int sz,int sgx,int sgy) && oz[n][0]==z) { attr((n+1)&0x1f); bprintf("\x1b[%d;%dH%c",ogy[n][0]+7,ogx[n][0]+35, - active[n][0]); + active[n][0]); attr((n+1)); } /********************************************/ /* Erase the other guy if he left the room! */ @@ -1080,8 +1081,8 @@ void read_player_message() ******************************************************************************/ void send_message(int nodes) { - int file,num,n; - char ch,fname[81],str[256],str1[256],count=0,chbuf[8]; + int num,n; + char str[256],str1[256],count=0,chbuf[8]; if(!nodes) { bprintf("\x1b[18;0H\x1b[K\1r\1hYou are the only player!\1n"); @@ -1198,7 +1199,8 @@ void perform_daily_maintenance(int maint_only) for (y=0;y<3;y++) { for(z=0;z<18;z++) { if(level<5 && level>1) ch=y+NUM_WEAPON+1; - else ch=y+4+NUM_WEAPON; val=0; + else ch=y+4+NUM_WEAPON; + val=0; fwrite(&ch,1,1,stream); fwrite(&val,1,1,stream); } @@ -1207,7 +1209,8 @@ void perform_daily_maintenance(int maint_only) for (y=0;y<3;y++) { for(z=0;z<18;z++) { if(level<5 && level>1) ch=y+NUM_ARMOR; - else ch=y+3+NUM_ARMOR; val=0; + else ch=y+3+NUM_ARMOR; + val=0; fwrite(&ch,1,1,stream); fwrite(&val,1,1,stream); } diff --git a/xtrn/tbd/tbd2.c b/xtrn/tbd/tbd2.c index 4ff2bec493..5877b9597b 100644 --- a/xtrn/tbd/tbd2.c +++ b/xtrn/tbd/tbd2.c @@ -3,76 +3,87 @@ ******************************************************************************/ #include "tbd_pack.h" - int in_shop=0; long cost_per_min=0L,total_cost=0L,times_per_day=0L; user_t user; rmobj_t rmobj[55]; rmobj_t rmcmp[55]; +// NOTE (TODO): This list of object does not match objects.h, diff: +/* + * < 4,(BLINK|YELLOW),'.',"Magical Key",0,0, + * < 4,(BLINK|LIGHTRED),'.',"Staff of Power",0,0, + * + * > 4,(YELLOW),'.',"Magical Key",0,0, + * > 4,(LIGHTRED),'.',"Staff of Power",0,0, + * + * < 4,(BROWN),'F',"Food",0,0, + * > 4,(BROWN),'F',"Food",0,9, + */ object_t object[62]={ - 0,0,' '," ",0,0, - 1,(BLUE),'',"Dagger",0,4, - 1,(LIGHTBLUE),'',"Long Dagger",1250,5, /* is the damage */ - 1,(LIGHTGREEN),'',"Short Sword",2500,6, /* that they do */ - 1,(LIGHTCYAN),'',"Long Sword",3740,7, - 1,(LIGHTRED),'',"Broad Sword",4360,8, - 1,(LIGHTMAGENTA),'',"Bastard Sword",4680,9, - 1,(YELLOW),'',"2-Handed Sword",4840,10, - 2,(LIGHTBLUE),'�',"Leather Armor",1250,1, /* Misc for Armor */ - 2,(LIGHTGREEN),'�',"Studded Armor",2500,2, /* is their A.C. */ - 2,(LIGHTCYAN),'�',"Scale Armor",3740,3, - 2,(LIGHTRED),'�',"Chain Armor",4360,4, - 2,(LIGHTMAGENTA),'�',"Banded Armor",4680,5, - 2,(YELLOW),'�',"Plate Armor",4840,6, - 3,(YELLOW),'$',"",0,0, - 4,(LIGHTBLUE),'�',"Warp 2 Other Scroll",100,1, - 4,(LIGHTBLUE),'�',"Invisibilty Potion",2500,2, /* 30 seconds */ - 4,(LIGHTGREEN),'�',"Healing Potion",500,3, /* 1-5 points */ - 4,(LIGHTGREEN),'�',"Scroll of Xtra Heal",1000,4, /* 2-10 points */ - 4,(LIGHTMAGENTA),'�',"Mystery Scroll",200,7, - 4,(LIGHTMAGENTA),'�',"Mystery Potion",200,8, - 4,(LIGHTRED),'�', "Ring of Resurrect",2500,0, - 4,(LIGHTCYAN),'�',"Potion of Full Heal",2500,5, - 4,(YELLOW),'�',"Potion of Strength",1500,6, - 4,(YELLOW),'',"Magical Key",0,0, - 4,(LIGHTRED),'�',"Staff of Power",0,0, - 4,(WHITE),'@',"Magical Compass",0,0, - 4,(BROWN),'F',"Food",0,9, - 5,(YELLOW),'�',"Stairs Going Up (+ to climb up)",0,0, - 5,(LIGHTGREEN),'�',"Stairs Going Down (+ to climb down)",0,1, - 6,(LIGHTCYAN),'�',"Weapons Shop Shopkeeper",0,1, - 6,(LIGHTGREEN),'�',"Armor Shop Shopkeeper",0,2, - 6,(LIGHTRED),'�',"Specialty Store Shopkeeper",0,3, - 7,(LIGHTBLUE),'�',"a Giant Caterpillar",1,1, /* Gold first - */ - 7,(LIGHTGREEN),'�',"a Frag",1,1, /* then level */ - 7,(BROWN),'�',"a Giant Snail",1,2, - 7,(LIGHTRED),'�',"a Deadly Crab",2,2, - 7,(LIGHTCYAN),'�',"a Rattlesnake",2,3, - 7,(LIGHTBLUE),'�',"a Giant",3,3, - 7,(YELLOW),'�',"a Brainsucker",3,4, - 7,(LIGHTMAGENTA),'�',"a Bonecrusher",4,4, - 7,(BLUE),'�',"a Thraxion Stabber",4,5, - 7,(GREEN),'�',"a Conehead",5,5, - 7,(RED),'�',"a Snubber",5,6, - 7,(MAGENTA),'�',"a Little Bojay",6,6, - 7,(LIGHTMAGENTA),'�',"a Big Bojay",6,7, - 7,(BLUE),'�',"a Little Flerp",7,7, - 7,(LIGHTBLUE),'�',"a Big Flerp",7,8, - 7,(LIGHTRED),'�',"a Neck Puller",8,8, - 7,(LIGHTCYAN),'�',"an Inhaler",8,9, - 7,(YELLOW),'�',"a Hunchback",9,9, - 7,(GREEN),'�',"a Creeping Moss",9,10, - 7,(YELLOW),'�',"a Killer Hornet",10,10, - 7,(WHITE),'�',"a Zombie",10,10, - 7,(LIGHTBLUE),'�',"a Killer Mantis",0,15, - 7,(LIGHTRED),'�',"The Beast",0,20, - 8,(GREEN),'',"Tree",0,0, - 8,(YELLOW),'�',"Quicksand",0,0, - 8,(MAGENTA),'',"Pillar",0,0, - 8,(WHITE),'�',"Pillar",0,0, - 8,(BLUE),'�',"Water",0,0, - 8,(WHITE),'�',"Rock",0,0 + { 0,0,' '," ",0,0 }, + { 1,(BLUE),'',"Dagger",0,4 }, + { 1,(LIGHTBLUE),'',"Long Dagger",1250,5 }, /* is the damage */ + { 1,(LIGHTGREEN),'',"Short Sword",2500,6 }, /* that they do */ + { 1,(LIGHTCYAN),'',"Long Sword",3740,7 }, + { 1,(LIGHTRED),'',"Broad Sword",4360,8 }, + { 1,(LIGHTMAGENTA),'',"Bastard Sword",4680,9 }, + { 1,(YELLOW),'',"2-Handed Sword",4840,10 }, + { 2,(LIGHTBLUE),'�',"Leather Armor",1250,1 }, /* Misc for Armor */ + { 2,(LIGHTGREEN),'�',"Studded Armor",2500,2 }, /* is their A.C. */ + { 2,(LIGHTCYAN),'�',"Scale Armor",3740,3 }, + { 2,(LIGHTRED),'�',"Chain Armor",4360,4 }, + { 2,(LIGHTMAGENTA),'�',"Banded Armor",4680,5 }, + { 2,(YELLOW),'�',"Plate Armor",4840,6 }, + { 3,(YELLOW),'$',"",0,0 }, + { 4,(LIGHTBLUE),'�',"Warp 2 Other Scroll",100,1 }, + { 4,(LIGHTBLUE),'�',"Invisibilty Potion",2500,2 }, /* 30 seconds */ + { 4,(LIGHTGREEN),'�',"Healing Potion",500,3 }, /* 1-5 points */ + { 4,(LIGHTGREEN),'�',"Scroll of Xtra Heal",1000,4 }, /* 2-10 points */ + { 4,(LIGHTMAGENTA),'�',"Mystery Scroll",200,7 }, + { 4,(LIGHTMAGENTA),'�',"Mystery Potion",200,8 }, + { 4,(LIGHTRED),'�', "Ring of Resurrect",2500,0 }, + { 4,(LIGHTCYAN),'�',"Potion of Full Heal",2500,5 }, + { 4,(YELLOW),'�',"Potion of Strength",1500,6 }, + { 4,(YELLOW),'',"Magical Key",0,0 }, + { 4,(LIGHTRED),'�',"Staff of Power",0,0 }, + { 4,(WHITE),'@',"Magical Compass",0,0 }, + { 4,(BROWN),'F',"Food",0,9 }, + { 5,(YELLOW),'�',"Stairs Going Up (+ to climb up)",0,0 }, + { 5,(LIGHTGREEN),'�',"Stairs Going Down (+ to climb down)",0,1 }, + { 6,(LIGHTCYAN),'�',"Weapons Shop Shopkeeper",0,1 }, + { 6,(LIGHTGREEN),'�',"Armor Shop Shopkeeper",0,2 }, + { 6,(LIGHTRED),'�',"Specialty Store Shopkeeper",0,3 }, + { 7,(LIGHTBLUE),'�',"a Giant Caterpillar",1,1 }, /* Gold first - */ + { 7,(LIGHTGREEN),'�',"a Frag",1,1 }, /* then level */ + { 7,(BROWN),'�',"a Giant Snail",1,2 }, + { 7,(LIGHTRED),'�',"a Deadly Crab",2,2 }, + { 7,(LIGHTCYAN),'�',"a Rattlesnake",2,3 }, + { 7,(LIGHTBLUE),'�',"a Giant",3,3 }, + { 7,(YELLOW),'�',"a Brainsucker",3,4 }, + { 7,(LIGHTMAGENTA),'�',"a Bonecrusher",4,4 }, + { 7,(BLUE),'�',"a Thraxion Stabber",4,5 }, + { 7,(GREEN),'�',"a Conehead",5,5 }, + { 7,(RED),'�',"a Snubber",5,6 }, + { 7,(MAGENTA),'�',"a Little Bojay",6,6 }, + { 7,(LIGHTMAGENTA),'�',"a Big Bojay",6,7 }, + { 7,(BLUE),'�',"a Little Flerp",7,7 }, + { 7,(LIGHTBLUE),'�',"a Big Flerp",7,8 }, + { 7,(LIGHTRED),'�',"a Neck Puller",8,8 }, + { 7,(LIGHTCYAN),'�',"an Inhaler",8,9 }, + { 7,(YELLOW),'�',"a Hunchback",9,9 }, + { 7,(GREEN),'�',"a Creeping Moss",9,10 }, + { 7,(YELLOW),'�',"a Killer Hornet",10,10 }, + { 7,(WHITE),'�',"a Zombie",10,10 }, + { 7,(LIGHTBLUE),'�',"a Killer Mantis",0,15 }, + { 7,(LIGHTRED),'�',"The Beast",0,20 }, + { 8,(GREEN),'',"Tree",0,0 }, + { 8,(YELLOW),'�',"Quicksand",0,0 }, + { 8,(MAGENTA),'',"Pillar",0,0 }, + { 8,(WHITE),'�',"Pillar",0,0 }, + { 8,(BLUE),'�',"Water",0,0 }, + { 8,(WHITE),'�',"Rock",0,0 } }; + /****************************************************************************** This function draws the room you are currently in (it also automatically calls the 'draw_others' routine to draw any other people in the room. @@ -489,7 +500,7 @@ void game_commands(int menu,int line) ******************************************************************************/ long read_user(int get_empty) { - int file,x,count; + int file,count; char buf[USER_T_SIZE]; record_number=0L; @@ -502,7 +513,8 @@ long read_user(int get_empty) while(!ateof) { count=0; while(lock(file,record_number*(long)(USER_T_SIZE), - (long)(USER_T_SIZE)) && count++<500); + (long)(USER_T_SIZE)) && count++<500) + ; if(!read(file,buf,USER_T_SIZE)) ateof=1; unpack_user_t_struct(&user, buf); @@ -618,7 +630,7 @@ void get_room_objects(int level,int room,int display) } } if(!z) in_shop=0; - } + } } /****************************************************************************** This function compares room objects from the last read @@ -1022,7 +1034,7 @@ int player_attack(int player,uchar level,int ac,int symbol) char str[256]; uchar x; int hitchance=70,file; - + if(user.level>level) hitchance+=(user.level-level)*2; else if(user.level<level) @@ -1052,9 +1064,8 @@ int player_attack(int player,uchar level,int ac,int symbol) ******************************************************************************/ int attack_monster(uchar level) { - char str[256]; int hitchance=70,x; - + if(user.level>level) hitchance+=(user.level-level)*2; else if(user.level<level) @@ -1076,7 +1087,7 @@ void monster_attack(uchar level) char str[256]; uchar x=0,temp; int hitchance=70,file; - + if(user.level<level) hitchance+=(level-user.level)*2; else if(user.level>level) @@ -1221,8 +1232,12 @@ void monster_check(int gx,int gy) if(object[rmobj[((gy+y)*11)+(gx+x)].item].type==MONSTER && count<100 && (clock_tick>=18 || (object[rmobj[((gy+y)*11)+ (gx+x)].item].misc>9 && clock_tick>=9))) { - if(y<0) my=1; if(x<0) mx=1; if(y==0) my=0; - if(x==0) mx=0; if(y>0) my=-1; if(x>0) mx=-1; + if(y<0) my=1; + if(x<0) mx=1; + if(y==0) my=0; + if(x==0) mx=0; + if(y>0) my=-1; + if(x>0) mx=-1; if(!(rmobj[((gy+(y+my))*11)+(gx+(x+mx))].item) && !(initial_inway(user.mapx,user.mapy,user.mapz, (x+mx+gx),(y+my+gy)))) { -- GitLab