Chainbox.mod........ Altair #1 @14259 Mon Feb 15 13:43:29 1993 2[4Status2] :1 No Reply Necessary. Altair 1 @14259 LINK or 1 @4259 NET Mon Febuary 15, 1993 11:50:00 am Mod Name Chainbox.mod Version WWIV 4.22 Difficulty Easy.... All credit for this mode goes to ziggy and the President. I just revised it for version 422. 様様様様様様様様様様様様様様様様様様様様様様様様様様様様様様様様様様様様様様様 CHAINBOX.MOD This is an interesting mod which saves the number of times each chain file has been run and then displays it in the online game menu. Nicer presentations of this menu also have been included, providing color, in two columns. ============================================================================= Legend: - = Existing Code + = Add * = Modify Note - I would consider backing up your source before adding this. It's always a good idea. just do pkunzip -a source *.c *.h. 1. First of all, you must realize that since this mod changes the structure of the chain files, you will have to delete your CHAINS.DAT file and re-enter each chain. Just write down what you need to remember. 2. First, load up VARDEC.H and search for this code and make the changes shown. - /* DATA FOR OTHER PROGRAMS AVAILABLE */ - typedef struct { - char filename[81], /* filename for .chn file */ - description[81]; /* description of it */ - unsigned char sl, /* seclev restriction */ - ansir; /* if ANSI required */ - unsigned short ar; /* AR restriction */ + int used; /* Number of times used */ - } chainfilerec; Note - If you think the number of times used will exceed 32767 (I doubt it) then change it to unsigned int used; 3. Next we have to initialize this variable when each chain is created. Search for void insert_chain in CHNEDIT.C and make these changes. - void insert_chain (int n) - { - chainfilerec c; - int i,i1,nu; - - for (i=numchain-1; i>=n; i--) - chains[i+1]=chains[i]; - strcpy(c.description,get_string(127)); - strcpy(c.filename,get_string(128)); - c.sl=10; - c.ar=0; - c.ansir=0; + c.used=0; - chains[n]=c; - ++numchain; - modify_chain(n); - } 4. Now we have to increment the number of times used each time it is run, and save. Make these changes in function void run_chain in BBSUTL1.C. - void run_chain(int cn) - { * char s[255],s[81],s1[81],s2[81],s3[81],s4[81]; - int oc, f; - long l; - - itoa(com_speed, s1, 10); - itoa(syscfg.primaryport,s2,10); - itoa(modem_speed, s3, 10); + chains[cn].used++; + strcpy (s4,syscfg.datadir); + strcat(s4,"CHAINS.DAT"); + f = open(s4,O_RDWR | O_BINARY | O_CREAT | O_TRUNC, S_IREAD | S_IWRITE); + write(f,(void *)chains, numchain * sizeof(chainfilerec)); + close (f); - stuff_in(s,chains[cn].filename,creat_chain_file("CHAIN.TXT"),s1,s2,s3, ""); - sprintf(s2,get_string(1,35),chains[cn].description); 5. Now, we have to present this statistic in the menu. Load up BBSUTL1.C and look for void show_chains(...) and replace it with this one. void show_chains(int *mapp, int *map) { int abort,i,i1,c,l; char s[81],s2[81],s3[81],s4[81],s5[81]; c=0; abort=0; clearscreen(); nl(); pl(" 2-=[4On-Line Games2]=-"); /* change to what ever you want */ nl(); prt(3," # Description Used # Description Used "); nl(); nl(); for (i=0; (i<*mapp) && (!abort) && (!hangup); i+=2) { ansic(c+1); itoa(i+1,s2,10); itoa(chains[map[i]].used,s3,10); if ((i+2)<=*mapp){ itoa (i+2,s4,10); itoa (chains[map[i+1]].used,s5,10); sprintf(s,"%2s. %-25s %-5s %2s. %-25s %-5s",s2,(chains[map[i]].description),s3,s4,(chains[map[i+1]].description),s5); }else sprintf(s,"%2s. %-25s %-5s",s2,(chains[map[i]].description),s3); pla(s,&abort); c^=1; } nl(); ansic(3); } 6. okay now in com.c at the end put in void clearscreen(void). also make sure to update your fcns.h file. void clearscreen(void) { if (okansi()) { outchr(12); outstr("\x0c"); } else { outchr(12); } } 7. Ok, thats it. Now recompile the Whole BBS. (You modified VARDEC.H).... Also Remove the old chains vea-chainedit and reinstall them. (You changed the format of chain.dat). Standard Disclamer: You put it in. How could it be my fault.