diff -c -r -w mangband-015/src/Makefile mangband-021/src/Makefile *** mangband-015/src/Makefile Tue Apr 29 14:51:09 1997 --- mangband-021/src/Makefile Wed Apr 30 18:10:04 1997 *************** *** 75,81 **** common/z-util.c common/z-virt.c common/z-form.c common/z-rand.c \ common/net-unix.c common/sockbuf.c common/net-ibm.c \ client/z-term.c client/c-util.c client/c-cmd.c client/c-inven.c \ ! client/c-files.c client/c-tables.c \ client/variable.c client/main-ibm.c client/main-cap.c client/main-gcu.c \ client/main-x11.c client/main-xaw.c client/netclient.c \ client/c-xtra1.c client/c-xtra2.c client/c-spell.c client/client.c --- 75,81 ---- common/z-util.c common/z-virt.c common/z-form.c common/z-rand.c \ common/net-unix.c common/sockbuf.c common/net-ibm.c \ client/z-term.c client/c-util.c client/c-cmd.c client/c-inven.c \ ! client/c-files.c client/c-tables.c client/c-store.c \ client/variable.c client/main-ibm.c client/main-cap.c client/main-gcu.c \ client/main-x11.c client/main-xaw.c client/netclient.c \ client/c-xtra1.c client/c-xtra2.c client/c-spell.c client/client.c *************** *** 84,90 **** common/z-util.o common/z-virt.o common/z-form.o common/z-rand.o \ common/net-unix.o common/sockbuf.o common/net-ibm.o \ client/z-term.o client/c-util.o client/c-cmd.o client/c-inven.o \ ! client/c-files.o client/c-tables.o \ client/variable.o client/main-ibm.o client/main-cap.o client/main-gcu.o \ client/main-x11.o client/main-xaw.o client/netclient.o \ client/c-xtra1.o client/c-xtra2.o client/c-spell.o client/client.o --- 84,90 ---- common/z-util.o common/z-virt.o common/z-form.o common/z-rand.o \ common/net-unix.o common/sockbuf.o common/net-ibm.o \ client/z-term.o client/c-util.o client/c-cmd.o client/c-inven.o \ ! client/c-files.o client/c-tables.o client/c-store.o \ client/variable.o client/main-ibm.o client/main-cap.o client/main-gcu.o \ client/main-x11.o client/main-xaw.o client/netclient.o \ client/c-xtra1.o client/c-xtra2.o client/c-spell.o client/client.o *************** *** 138,150 **** # including "USE_GETCH" and "USE_CURS_SET". Note that "config.h" will # attempt to "guess" at many of these flags based on your system. # ! CFLAGS = -Wall -g -pipe -D"USE_GCU" \ ! -DSTDVA -DSOLARIS ! LIBS = -lcurses -ltermcap -lsocket - #LIBS = -L/usr/X11R6/lib -lX11 -lncurses -ltermcap - ## ## Variation -- Only support "main-x11.c" (not "main-gcu.c") ## --- 138,147 ---- # including "USE_GETCH" and "USE_CURS_SET". Note that "config.h" will # attempt to "guess" at many of these flags based on your system. # ! CFLAGS = -Wall -g -pipe -D"USE_X11" -D"USE_GCU" -I/usr/include/ncurses ! LIBS = -L/usr/X11R6/lib -lX11 -lncurses -ltermcap ## ## Variation -- Only support "main-x11.c" (not "main-gcu.c") ## Common subdirectories: mangband-015/src/client and mangband-021/src/client Common subdirectories: mangband-015/src/common and mangband-021/src/common diff -c -r -w mangband-015/src/config.h mangband-021/src/config.h *** mangband-015/src/config.h Sun Mar 23 14:49:28 1997 --- mangband-021/src/config.h Sun May 4 04:14:41 1997 *************** *** 350,361 **** /* * OPTION: Allow the use of "sound" in various places. */ ! #define USE_SOUND /* * OPTION: Allow the use of "graphics" in various places */ ! #define USE_GRAPHICS /* --- 350,361 ---- /* * OPTION: Allow the use of "sound" in various places. */ ! /* #define USE_SOUND */ /* * OPTION: Allow the use of "graphics" in various places */ ! /* #define USE_GRAPHICS */ /* *************** *** 471,476 **** --- 471,481 ---- /* + * OPTION: Have the server respond to commands typed in on its tty. + */ + #define SERVER_CONSOLE + + /* * OPTION: Default font (when using X11). */ #define DEFAULT_X11_FONT "9x15" Common subdirectories: mangband-015/src/server and mangband-021/src/server diff -c -r -w mangband-015/src/client/c-cmd.c mangband-021/src/client/c-cmd.c *** mangband-015/src/client/c-cmd.c Sun Apr 27 16:41:22 1997 --- mangband-021/src/client/c-cmd.c Fri May 2 22:18:22 1997 *************** *** 325,331 **** /* Send the request */ Send_map(); ! /* Wait */ inkey(); /* Reload the screen */ --- 325,335 ---- /* Send the request */ Send_map(); ! /* Reset the line counter */ ! last_line_info = 0; ! ! /* Wait until we get the whole thing */ ! while (last_line_info < 23) inkey(); /* Reload the screen */ Only in mangband-015/src/client: c-cmd.o diff -c -r -w mangband-015/src/client/c-files.c mangband-021/src/client/c-files.c *** mangband-015/src/client/c-files.c Sun Apr 27 17:41:35 1997 --- mangband-021/src/client/c-files.c Tue Apr 29 20:53:52 1997 *************** *** 240,248 **** --- 240,250 ---- */ errr path_parse(char *buf, int max, cptr file) { + #ifndef WIN32 cptr u, s; struct passwd *pw; char user[128]; + #endif /* WIN32 */ /* Assume no result */ *************** *** 258,263 **** --- 260,268 ---- return (0); } + /* Windows should never have ~ in filename */ + #ifndef WIN32 + /* Point at the user */ u = file+1; *************** *** 294,299 **** --- 299,305 ---- /* Success */ return (0); + #endif /* WIN32 */ } Only in mangband-015/src/client: c-files.o Only in mangband-015/src/client: c-inven.o Only in mangband-015/src/client: c-spell.o Only in mangband-021/src/client: c-store.c Only in mangband-015/src/client: c-tables.o diff -c -r -w mangband-015/src/client/c-util.c mangband-021/src/client/c-util.c *** mangband-015/src/client/c-util.c Mon Apr 28 15:58:24 1997 --- mangband-021/src/client/c-util.c Wed Apr 30 22:56:23 1997 *************** *** 1140,1145 **** --- 1140,1162 ---- /* Paranoia */ if (!command_cmd) command_cmd = ESCAPE; + /* Shopping */ + if (shopping) + { + /* Convert */ + switch (command_cmd) + { + /* Command "p" -> "purchase" (get) */ + case 'p': command_cmd = 'g'; break; + + /* Command "m" -> "purchase" (get) */ + case 'm': command_cmd = 'g'; break; + + /* Command "s" -> "sell" (drop) */ + case 's': command_cmd = 'd'; break; + } + } + /* Hack -- erase the message line. */ prt("", 0, 0); } *************** *** 1725,1732 **** --- 1742,1760 ---- return (0); } + void clear_from(int row) + { + int y; + /* Erase requested rows */ + for (y = row; y < Term->hgt; y++) + { + /* Erase part of the screen */ + Term_erase(0, y, 255); + } + } + #ifdef SET_UID # ifndef HAS_USLEEP *************** *** 1771,1776 **** return 0; } ! # endif ! #endif --- 1799,1811 ---- return 0; } ! # endif /* HAS_USLEEP */ ! #endif /* SET_UID */ ! ! #ifdef WIN32 ! int usleep(long microSeconds) ! { ! Sleep(microSeconds/10); /* meassured in milliseconds not microseconds*/ ! } ! #endif /* WIN32 */ Only in mangband-015/src/client: c-util.o Only in mangband-015/src/client: c-xtra1.o Only in mangband-015/src/client: c-xtra2.o diff -c -r -w mangband-015/src/client/client.c mangband-021/src/client/client.c *** mangband-015/src/client/client.c Sun Apr 27 17:21:22 1997 --- mangband-021/src/client/client.c Sun May 4 12:36:04 1997 *************** *** 18,23 **** --- 18,26 ---- /* Hack -- No messages yet */ message__tail = MESSAGE_BUF; + + /* Initialize room for the store's stock */ + C_MAKE(store.stock, 24, object_type); } /* *************** *** 177,182 **** --- 180,188 ---- /* See if we have a command waiting */ request_command(FALSE); + /* Hack -- ignore any commands until the screen is redrawn */ + if (last_line_info < 22) continue; + if (command_cmd) { process_command(); *************** *** 303,308 **** --- 309,316 ---- sscanf(buf, "class %hd", &class); if (!strncmp(buf, "sex", 3)) sscanf(buf, "sex %hd", &sex); + if (!strncmp(buf, "end", 3)) + break; } fclose(config); Only in mangband-015/src/client: client.o diff -c -r -w mangband-015/src/client/externs.h mangband-021/src/client/externs.h *** mangband-015/src/client/externs.h Sun Apr 27 17:44:35 1997 --- mangband-021/src/client/externs.h Fri May 2 22:09:50 1997 *************** *** 28,37 **** --- 28,47 ---- extern object_type inventory[INVEN_TOTAL]; extern char inventory_name[INVEN_TOTAL][80]; + extern store_type store; + extern owner_type store_owner; + extern int store_prices[24]; + extern char store_names[24][80]; + extern s16b store_num; + extern char spell_info[9][9][80]; extern setup_t Setup; + extern bool shopping; + + extern s16b last_line_info; + extern s16b command_see; extern s16b command_gap; extern s16b command_wrk; *************** *** 238,243 **** --- 248,254 ---- extern s16b c_get_quantity(cptr prompt, int max); extern errr path_build(char *buf, int max, cptr path, cptr file); extern bool askfor_aux(char *buf, int len); + extern void clear_from(int row); /* c-spell.c */ extern void show_browse(int book); *************** *** 245,250 **** --- 256,265 ---- extern void do_cast(int book); extern void do_pray(int book); + /* c-store.c */ + extern void display_inventory(void); + extern void display_store(void); + /* c-xtra1.c */ extern void prt_stat(int stat, int max, int cur); extern void prt_title(cptr title); *************** *** 317,322 **** --- 332,341 ---- extern int Send_cast(int book, int spell); extern int Send_pray(int book, int spell); extern int Send_map(void); + extern int Send_store_purchase(int item, int amt); + extern int Send_store_sell(int item, int amt); + extern int Send_store_leave(void); + extern int Send_store_confirm(void); Only in mangband-015/src/client: main-cap.o diff -c -r -w mangband-015/src/client/main-gcu.c mangband-021/src/client/main-gcu.c *** mangband-015/src/client/main-gcu.c Tue Apr 29 14:50:24 1997 --- mangband-021/src/client/main-gcu.c Thu May 1 17:49:39 1997 *************** *** 50,56 **** * Include the proper "header" file */ #ifdef USE_NCURSES ! # include #else # include #endif --- 50,56 ---- * Include the proper "header" file */ #ifdef USE_NCURSES ! # include #else # include #endif Only in mangband-015/src/client: main-gcu.o Only in mangband-015/src/client: main-ibm.o diff -c -r -w mangband-015/src/client/main-win.c mangband-021/src/client/main-win.c *** mangband-015/src/client/main-win.c Fri Mar 14 14:08:36 1997 --- mangband-021/src/client/main-win.c Sat May 3 13:04:28 1997 *************** *** 71,81 **** #include "angband.h" - #ifdef WINDOWS /* * Extract the "WIN32" flag from the compiler */ #if defined(__WIN32__) || defined(__WINNT__) || defined(__NT__) --- 71,269 ---- #include "angband.h" #ifdef WINDOWS + /* Borrowed from server side because I think they are + * appropriate here (they are called by some functions) -GP */ + /* + * Standard window names + */ + cptr ang_term_name[8] = + { + "Angband", + "Mirror", + "Recall", + "Choice", + "Term-4", + "Term-5", + "Term-6", + "Term-7" + }; + /* menu support removed -GP */ + /*#define MNU_SUPPORT*/ + + + /* prototype for client.c functions */ + static int Socket; + extern void process_command(); + + + /* HACK couldn't ever load this function */ + static void init_arrays(void) + { + /* Macro variables */ + C_MAKE(macro__pat, MACRO_MAX, cptr); + C_MAKE(macro__act, MACRO_MAX, cptr); + C_MAKE(macro__cmd, MACRO_MAX, bool); + + /* Macro action buffer */ + C_MAKE(macro__buf, 1024, char); + + /* Message variables */ + C_MAKE(message__ptr, MESSAGE_MAX, u16b); + C_MAKE(message__buf, MESSAGE_BUF, char); + + /* Hack -- No messages yet */ + message__tail = MESSAGE_BUF; + + /* Initialize room for the store's stock */ + C_MAKE(store.stock, 24, object_type); + + } + + + static void initalize_all_pref_files(void) + { + char buf[1024]; + + + /* Access the "basic" pref file */ + strcpy(buf, "pref.prf"); + + /* Process that file */ + process_pref_file(buf); + + /* Access the "user" pref file */ + sprintf(buf, "user.prf"); + + /* Process that file */ + process_pref_file(buf); + + /* Access the "basic" system pref file */ + sprintf(buf, "pref-%s.prf", ANGBAND_SYS); + + /* Process that file */ + process_pref_file(buf); + + /* Access the "visual" system pref file (if any) */ + sprintf(buf, "%s-%s.prf", (use_graphics ? "graf" : "font"), ANGBAND_SYS); + + /* Process that file */ + process_pref_file(buf); + + /* Access the "user" system pref file */ + sprintf(buf, "user-%s.prf", ANGBAND_SYS); + + /* Process that file */ + process_pref_file(buf); + + + /* Access the "race" pref file */ + sprintf(buf, "%s.prf", race_title[race]); + buf[0] = tolower(buf[0]); + + /* Process that file */ + process_pref_file(buf); + + /* Access the "class" pref file */ + sprintf(buf, "%s.prf", class_title[class]); + buf[0] = tolower(buf[0]); + + /* Process that file */ + process_pref_file(buf); + + /* Access the "character" pref file */ + sprintf(buf, "%s.prf", nick); + buf[0] = tolower(buf[0]); + + /* Process that file */ + process_pref_file(buf); + } + + + static void Input_loop(void) + { + int netfd, result; + int last_sent; + + /* Initialize the last_sent variable */ + last_sent = time(NULL); + + if ((result = Net_input()) == -1) + { + plog("Bad server input"); + return; + } + + if (Net_flush() == -1) + return; + + if ((netfd = Net_fd()) == -1) + { + plog("Bad socket filedescriptor"); + return; + } + + for (;;) + { + if (Net_flush() == -1) + { + plog("Bad net flush"); + return; + } + + /* Set the timeout on the network socket */ + SetTimeout(0, 1000000 / Setup.frames_per_second); + + /* Only take input if we got some */ + if (SocketReadable(netfd)) + { + if ((result = Net_input()) == -1) + { + /*plog("Bad net input");*/ + return; + } + } + + /* See if we have a command waiting */ + request_command(FALSE); + + if (command_cmd) + { + process_command(); + last_sent = time(NULL); + } + + /* Clear the previous command */ + command_cmd = 0; + Term_flush(); + Term_fresh(); + } + } + /* + * A hook for "quit()". + * + * Close down, then fall back into "quit()". + */ + static void quit_hook(cptr s) + { + int j; + + for (j = 8 - 1; j >= 0; j--) + { + /* Unused */ + if (!ang_term[j]) continue; + + /* Nuke it */ + term_nuke(ang_term[j]); + } + } + + + + /* * Extract the "WIN32" flag from the compiler */ #if defined(__WIN32__) || defined(__WINNT__) || defined(__NT__) *************** *** 175,182 **** /* * Include the "windows" support file */ ! #include /* * exclude parts of MMSYSTEM.H that are not needed */ --- 363,371 ---- /* * Include the "windows" support file */ ! #include /* includes windows.h */ + /* * exclude parts of MMSYSTEM.H that are not needed */ *************** *** 413,421 **** static cptr ANGBAND_DIR_XTRA_FONT; static cptr ANGBAND_DIR_XTRA_GRAF; static cptr ANGBAND_DIR_XTRA_SOUND; - static cptr ANGBAND_DIR_XTRA_HELP; - /* * The Angband color set: * Black, White, Slate, Orange, Red, Blue, Green, Umber --- 602,608 ---- *************** *** 658,667 **** rc.right = rc.left + td->client_wid; rc.bottom = rc.top + td->client_hgt; - /* XXX XXX XXX */ - /* rc.right += 1; */ - /* rc.bottom += 1; */ - /* Adjust */ AdjustWindowRectEx(&rc, td->dwStyle, TRUE, td->dwExStyle); --- 845,850 ---- *************** *** 739,752 **** */ static void save_prefs(void) { char buf[32]; strcpy(buf, use_graphics ? "1" : "0"); WritePrivateProfileString("Angband", "Graphics", buf, ini_file); ! strcpy(buf, use_sound ? "1" : "0"); WritePrivateProfileString("Angband", "Sound", buf, ini_file); ! save_prefs_aux(&data[0], "Main window"); /* XXX XXX XXX XXX */ --- 922,939 ---- */ static void save_prefs(void) { + #if defined(USE_GRAPHICS) || defined(USE_SOUND) char buf[32]; + #endif + #ifdef USE_GRAPHICS strcpy(buf, use_graphics ? "1" : "0"); WritePrivateProfileString("Angband", "Graphics", buf, ini_file); ! #endif ! #ifdef USE_SOUND strcpy(buf, use_sound ? "1" : "0"); WritePrivateProfileString("Angband", "Sound", buf, ini_file); ! #endif save_prefs_aux(&data[0], "Main window"); /* XXX XXX XXX XXX */ *************** *** 802,807 **** --- 989,995 ---- /* * Hack -- load a "sound" preference by index and name */ + #ifdef USE_SOUND static void load_prefs_sound(int i) { char aux[128]; *************** *** 826,845 **** /* Save the sound filename, if it exists */ if (check_file(buf)) sound_file[i] = string_make(buf); } - /* * Load the preferences from the .INI file */ static void load_prefs(void) { int i; /* Extract the "use_graphics" flag */ use_graphics = (GetPrivateProfileInt("Angband", "Graphics", 0, ini_file) != 0); /* Extract the "use_sound" flag */ use_sound = (GetPrivateProfileInt("Angband", "Sound", 0, ini_file) != 0); /* Load window prefs */ load_prefs_aux(&data[0], "Main window"); --- 1014,1039 ---- /* Save the sound filename, if it exists */ if (check_file(buf)) sound_file[i] = string_make(buf); } + #endif /* * Load the preferences from the .INI file */ static void load_prefs(void) { + #ifdef USE_SOUND int i; + #endif + #ifdef USE_GRAPHICS /* Extract the "use_graphics" flag */ use_graphics = (GetPrivateProfileInt("Angband", "Graphics", 0, ini_file) != 0); + #endif + #ifdef USE_SOUND /* Extract the "use_sound" flag */ use_sound = (GetPrivateProfileInt("Angband", "Sound", 0, ini_file) != 0); + #endif /* Load window prefs */ load_prefs_aux(&data[0], "Main window"); *************** *** 861,868 **** --- 1055,1064 ---- load_prefs_aux(&data[7], "Term-7 window"); + #ifdef USE_SOUND /* Prepare the sounds */ for (i = 1; i < SOUND_MAX; i++) load_prefs_sound(i); + #endif } *************** *** 995,1002 **** */ static void term_window_resize(term_data *td) { - RECT rc; - POINT pt; /* Require window */ if (!td->w) return; --- 1191,1196 ---- *************** *** 1099,1104 **** --- 1293,1299 ---- /* Access the font file */ path_build(buf, 1024, ANGBAND_DIR_XTRA_FONT, base_font); + /* Verify file */ if (!check_file(buf)) return (1); *************** *** 1373,1402 **** /*** Function hooks needed by "Term" ***/ - - #if 0 - /* - * Initialize a new Term - */ - static void Term_init_win(term *t) - { - /* XXX Unused */ - } - - - /* - * Nuke an old Term - */ - static void Term_nuke_win(term *t) - { - /* XXX Unused */ - } - - #endif - - - /* * Interact with the User */ static errr Term_user_win(int n) --- 1568,1574 ---- *************** *** 1412,1418 **** static errr Term_xtra_win_react(void) { int i; ! static old_use_graphics = FALSE; --- 1584,1591 ---- static errr Term_xtra_win_react(void) { int i; ! /* I added this USE_GRAPHICS because we lost color support as well. -GP */ ! #ifdef USE_GRAPHICS static old_use_graphics = FALSE; *************** *** 1464,1471 **** /* Activate the palette if needed */ if (change) new_palette(); } - #ifdef USE_GRAPHICS /* XXX XXX XXX Check "use_graphics" */ --- 1637,1644 ---- /* Activate the palette if needed */ if (change) new_palette(); } + #endif /* no color support -gp */ #ifdef USE_GRAPHICS /* XXX XXX XXX Check "use_graphics" */ *************** *** 1967,1978 **** t->attr_blank = TERM_WHITE; t->char_blank = ' '; - #if 0 - /* Prepare the init/nuke hooks */ - t->init_hook = Term_init_win; - t->nuke_hook = Term_nuke_win; - #endif - /* Prepare the template hooks */ t->user_hook = Term_user_win; t->xtra_hook = Term_xtra_win; --- 2140,2145 ---- *************** *** 2000,2006 **** static void init_windows(void) { int i; ! term_data *td; --- 2167,2173 ---- static void init_windows(void) { int i; ! static char version[20]; term_data *td; *************** *** 2007,2013 **** /* Main window */ td = &data[0]; WIPE(td, term_data); ! td->s = "Angband 2.7.9v6"; td->keys = 1024; td->rows = 24; td->cols = 80; --- 2174,2183 ---- /* Main window */ td = &data[0]; WIPE(td, term_data); ! /* td->s = "MAngband 0.1.4"; */ ! sprintf(version, "MAngband %d.%d.%d", ! VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH); ! td->s = version; td->keys = 1024; td->rows = 24; td->cols = 80; *************** *** 2184,2194 **** int i; HMENU hm = GetMenu(data[0].w); ! /* Save player */ EnableMenuItem(hm, IDM_FILE_SAVE, MF_BYCOMMAND | (character_generated ? MF_ENABLED : MF_DISABLED | MF_GRAYED)); /* Exit with save */ EnableMenuItem(hm, IDM_FILE_EXIT, MF_BYCOMMAND | (character_generated ? MF_ENABLED : MF_DISABLED | MF_GRAYED)); --- 2354,2365 ---- int i; HMENU hm = GetMenu(data[0].w); ! #ifdef MNU_SUPPORT /* Save player */ EnableMenuItem(hm, IDM_FILE_SAVE, MF_BYCOMMAND | (character_generated ? MF_ENABLED : MF_DISABLED | MF_GRAYED)); + /* Exit with save */ EnableMenuItem(hm, IDM_FILE_EXIT, MF_BYCOMMAND | (character_generated ? MF_ENABLED : MF_DISABLED | MF_GRAYED)); *************** *** 2209,2222 **** CheckMenuItem(hm, IDM_WINDOWS_SCREEN + i, MF_BYCOMMAND | (data[i].visible ? MF_CHECKED : MF_UNCHECKED)); } ! /* Item "Graphics" */ CheckMenuItem(hm, IDM_OPTIONS_GRAPHICS, MF_BYCOMMAND | (use_graphics ? MF_CHECKED : MF_UNCHECKED)); ! /* Item "Sound" */ CheckMenuItem(hm, IDM_OPTIONS_SOUND, MF_BYCOMMAND | (use_sound ? MF_CHECKED : MF_UNCHECKED)); #ifdef BEN_HACK /* Item "Colors 16" */ --- 2380,2396 ---- CheckMenuItem(hm, IDM_WINDOWS_SCREEN + i, MF_BYCOMMAND | (data[i].visible ? MF_CHECKED : MF_UNCHECKED)); } ! #endif ! #ifdef USE_GRAPHICS /* Item "Graphics" */ CheckMenuItem(hm, IDM_OPTIONS_GRAPHICS, MF_BYCOMMAND | (use_graphics ? MF_CHECKED : MF_UNCHECKED)); ! #endif ! #ifdef USE_SOUND /* Item "Sound" */ CheckMenuItem(hm, IDM_OPTIONS_SOUND, MF_BYCOMMAND | (use_sound ? MF_CHECKED : MF_UNCHECKED)); + #endif #ifdef BEN_HACK /* Item "Colors 16" */ *************** *** 2256,2267 **** /* No args */ if (!*s) return; ! /* Extract filename */ strcat(savefile, s); ! /* Validate the file */ validate_file(savefile); ! /* Game in progress */ game_in_progress = TRUE; --- 2430,2442 ---- /* No args */ if (!*s) return; ! /* More stuff moved to server -GP ! // Extract filename strcat(savefile, s); ! // Validate the file validate_file(savefile); ! */ /* Game in progress */ game_in_progress = TRUE; *************** *** 2269,2275 **** disable_start(); /* Play game */ ! play_game(FALSE); } --- 2444,2450 ---- disable_start(); /* Play game */ ! /* play_game(FALSE); -changed to network call -GP */ } *************** *** 2278,2283 **** --- 2453,2459 ---- */ static void process_menus(WORD wCmd) { + #ifdef MNU_SUPPORT int i; OPENFILENAME ofn; *************** *** 2310,2316 **** break; } ! /* Open game */ case IDM_FILE_OPEN: { if (!initialized) --- 2486,2492 ---- break; } ! // Open game case IDM_FILE_OPEN: { if (!initialized) *************** *** 2338,2344 **** if (GetOpenFileName(&ofn)) { ! /* Load 'savefile' */ validate_file(savefile); game_in_progress = TRUE; disable_start(); --- 2514,2520 ---- if (GetOpenFileName(&ofn)) { ! // Load 'savefile' validate_file(savefile); game_in_progress = TRUE; disable_start(); *************** *** 2360,2380 **** } else { ! /* Save the game */ do_cmd_save_game(); } break; } /* Save and Exit */ case IDM_FILE_EXIT: { if (game_in_progress && character_generated) { ! /* Hack -- Forget messages */ msg_flag = FALSE; ! /* Save the game */ do_cmd_save_game(); } quit(NULL); --- 2536,2557 ---- } else { ! // Save the game do_cmd_save_game(); } break; } + /* Save and Exit */ case IDM_FILE_EXIT: { if (game_in_progress && character_generated) { ! // Hack -- Forget messages msg_flag = FALSE; ! // Save the game do_cmd_save_game(); } quit(NULL); *************** *** 2465,2471 **** /* XXX XXX XXX */ break; } ! case IDM_OPTIONS_GRAPHICS: { char buf[1024]; --- 2642,2649 ---- /* XXX XXX XXX */ break; } ! /* Currently no graphics options available. -GP */ ! #ifdef USE_GRAPHICS case IDM_OPTIONS_GRAPHICS: { char buf[1024]; *************** *** 2484,2490 **** /* Load the file */ process_pref_file(buf); ! #ifdef USE_GRAPHICS /* Use graphics */ --- 2662,2668 ---- /* Load the file */ process_pref_file(buf); ! #endif /* GP's USE_GRAPHICS */ #ifdef USE_GRAPHICS /* Use graphics */ *************** *** 2522,2527 **** --- 2700,2706 ---- #endif + #ifdef USE_GRAPHICS /* no support -GP */ /* React to changes */ Term_xtra_win_react(); *************** *** 2530,2536 **** break; } ! case IDM_OPTIONS_SOUND: { use_sound = !use_sound; --- 2709,2715 ---- break; } ! #endif case IDM_OPTIONS_SOUND: { use_sound = !use_sound; *************** *** 2572,2577 **** --- 2751,2757 ---- break; } } + #endif /* MNU_SUPPORT */ } *************** *** 3022,3027 **** --- 3202,3208 ---- } break; } + } return DefWindowProc(hWnd, uMsg, wParam, lParam); *************** *** 3230,3257 **** } - /* - * Fatal error (see "z-util.c") - */ - static void hook_core(cptr str) - { - /* Message */ - if (str) MessageBox(data[0].w, str, "Error", MB_OK); - /* Another message */ - MessageBox(data[0].w, "I will now attempt to save and quit.", - "Fatal error", MB_OK | MB_ICONSTOP); - - /* Save the player XXX XXX XXX */ - save_player(); - - /* Quit */ - quit(NULL); - } - - - - /*** Initialize ***/ --- 3411,3417 ---- *************** *** 3298,3339 **** /* Init the file paths */ init_file_paths(path); - #if 0 - /* Mega-Hack XXX XXX XXX */ - if (!check_dir(ANGBAND_DIR_APEX)) - { - mkdir(ANGBAND_DIR_APEX); - } - #endif - /* Hack -- Validate the paths */ ! validate_dir(ANGBAND_DIR_APEX); ! validate_dir(ANGBAND_DIR_BONE); ! validate_dir(ANGBAND_DIR_DATA); validate_dir(ANGBAND_DIR_EDIT); validate_dir(ANGBAND_DIR_FILE); validate_dir(ANGBAND_DIR_HELP); - validate_dir(ANGBAND_DIR_INFO); - validate_dir(ANGBAND_DIR_SAVE); validate_dir(ANGBAND_DIR_USER); ! validate_dir(ANGBAND_DIR_XTRA); ! /* Build the "font" path */ path_build(path, 1024, ANGBAND_DIR_XTRA, "font"); ! /* Allocate the path */ ANGBAND_DIR_XTRA_FONT = string_make(path); ! /* Validate the "font" directory */ validate_dir(ANGBAND_DIR_XTRA_FONT); ! /* Build the filename */ path_build(path, 1024, ANGBAND_DIR_XTRA_FONT, "8X13.FON"); ! /* Hack -- Validate the basic font */ validate_file(path); --- 3458,3489 ---- /* Init the file paths */ + init_file_paths(path); /* Hack -- Validate the paths */ ! ! /* validate_dir(ANGBAND_DIR_APEX); *//*on server */ validate_dir(ANGBAND_DIR_EDIT); validate_dir(ANGBAND_DIR_FILE); validate_dir(ANGBAND_DIR_HELP); validate_dir(ANGBAND_DIR_USER); ! validate_dir(ANGBAND_DIR_XTRA); /*sounds & graphics */ ! // Build the "font" path path_build(path, 1024, ANGBAND_DIR_XTRA, "font"); ! // Allocate the path ANGBAND_DIR_XTRA_FONT = string_make(path); ! // Validate the "font" directory validate_dir(ANGBAND_DIR_XTRA_FONT); ! // Build the filename path_build(path, 1024, ANGBAND_DIR_XTRA_FONT, "8X13.FON"); ! // Hack -- Validate the basic font validate_file(path); *************** *** 3370,3398 **** #endif - /* Build the "help" path */ - path_build(path, 1024, ANGBAND_DIR_XTRA, "help"); - /* Allocate the path */ - ANGBAND_DIR_XTRA_HELP = string_make(path); ! /* Validate the "help" directory */ ! /* validate_dir(ANGBAND_DIR_XTRA_HELP); */ ! /* Build the filename */ ! path_build(path, 1024, ANGBAND_DIR_FILE, "news.txt"); ! /* Hack -- Validate the "news.txt" file */ ! validate_file(path); } int FAR PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nCmdShow) { int i; WNDCLASS wc; HDC hdc; --- 3520,3739 ---- #endif + } ! bool init_network() ! { ! sockbuf_t ibuf; ! unsigned magic = 12345; ! unsigned char reply_to, status; ! int login_port; ! int bytes; ! bool done = FALSE; ! int i; ! char real_name[17]; ! char host_name[80]; ! char buf[1024]; ! char nick[80]; ! char pass[20]; ! unsigned int version = MY_VERSION; ! s32b temp; ! WORD wVersion; ! WSADATA wsaData; ! int err; ! char user_name[80]; ! DWORD result, name_size = 80; ! char testhost[80]; /* get host from INI not command line*/ ! GetPrivateProfileString("MAngband", "host", "dcomp.com", ! testhost, 70, ini_file); + /* get user name */ + result = WNetGetUser(NULL, (LPSTR) user_name, &name_size); + if (result == NO_ERROR) + { + strncpy(real_name,user_name,16); + real_name[16] = '\0'; + } else strcpy (real_name, "PLAYER"); ! /* Initialize sockets */ ! wVersion = MAKEWORD (2, 0); ! err = WSAStartup( wVersion, &wsaData); ! if (err != 0) ! { ! /* couldn't initialize sockets */ ! MessageBox(data[0].w, "Couldn't initialize sockets.", "Error", MB_OK | MB_ICONSTOP); ! return FALSE; ! } ! GetLocalHostName(host_name, 80); ! ! /* get name and password from INI file */ ! GetPrivateProfileString("MAngband", "nick", real_name, ! nick, 70, ini_file); ! GetPrivateProfileString("MAngband", "pass", real_name, ! pass, 19, ini_file); ! ! /* get race, class, and sex from INI file */ ! GetPrivateProfileString("MAngband", "race", "0", ! buf, 10, ini_file); ! if (isdigit(buf[0])) ! race = atoi(buf); ! GetPrivateProfileString("MAngband", "class", "0", ! buf, 10, ini_file); ! if (isdigit(buf[0])) ! class = atoi(buf); ! GetPrivateProfileString("MAngband", "sex", "0", ! buf, 10, ini_file); ! if (isdigit(buf[0])) ! sex = atoi(buf); ! ! ! /* Verify that we have a nickname and password */ ! if (!strlen(nick)) ! strcpy(nick, "PLAYER"); ! if (!strlen(pass)) ! strcpy(pass, nick); ! ! /* Capitalize first letter in the name */ ! nick[0] = toupper(nick[0]); ! ! if ((Socket = CreateDgramSocket(0)) == -1) ! { ! printf("Could not create Dgram socket\n"); ! return FALSE; } + if (SetSocketNonBlocking(Socket, 1) == -1) + { + printf("Can't make socket non-blocking\n"); + return FALSE; + } + if (Sockbuf_init(&ibuf, Socket, CLIENT_SEND_SIZE, + SOCKBUF_READ | SOCKBUF_WRITE | SOCKBUF_DGRAM) == -1) + { + printf("No memory for socket buffer\n"); + return FALSE; + } + + Sockbuf_clear(&ibuf); + + Packet_printf(&ibuf, "%u", magic); + + Packet_printf(&ibuf, "%s%hu%c", real_name, GetPortNum(ibuf.sock), 0xFF); + + Packet_printf(&ibuf, "%s%s%hd%hd%hd%hu", nick, host_name, race, class, sex, version); + + if ((DgramConnect(Socket, testhost, 18346)) == -1) + { + printf("Couldn't connect to server.\n"); + printf("The server either isn't up, or you mistyped the host name.\n"); + exit(1); + } + + if ((bytes = DgramWrite(Socket, ibuf.buf, ibuf.len) == -1)) + { + printf("Couldn't send contact information\n"); + exit(1); + } + + + do + { + if(DgramRead(Socket, ibuf.buf, ibuf.size) <= 0) + { + /* printf("DgramReceiveAny failed\n");*/ + continue; + } + + Packet_scanf(&ibuf, "%c%c%d", &reply_to, &status, &temp); + + /* Hack -- set the login port correctly */ + login_port = (int) temp; + + break; + } while (1); + + if (status) + { + /* The server didn't like us.... */ + switch (status) + { + case E_VERSION: + plog("This version of the client will not work with that server."); + plog("Upgrade immediately to use this server."); + break; + case E_GAME_FULL: + plog("Sorry, the game is full. Try again later."); + break; + case E_IN_USE: + plog("That nickname is already in use. If it is your nickname,"); + plog("wait 30 seconds and try again."); + break; + case E_INVAL: + plog("The server didn't like your nickname, realname, or hostname."); + break; + default: + plog(format("Connection failed with status %d.", status)); + break; + } + + Net_cleanup(); + exit (1); + } + + /* Close our current connection */ + CleanupDgramSocket(Socket); + + err = WSACleanup(); + err = WSAStartup( wVersion, &wsaData); + if (err != 0) + { + /* couldn't initialize sockets */ + MessageBox(data[0].w, "Couldn't initialize sockets.", "Error", MB_OK | MB_ICONSTOP); + return FALSE; + } + + /* Connect to the server on the port it sent */ + if (Net_init(testhost, login_port) == -1) + { + printf("Network initialization failed!\n"); + return FALSE; + } + + if (Net_verify(real_name, nick, pass) == -1) + { + Net_cleanup(); + printf("Network verify failed!\n"); + return FALSE; + } + + if (Net_setup() == -1) + { + Net_cleanup(); + printf("Network setup failed!\n"); + return FALSE; + } + + if (Net_start() == -1) + { + Net_cleanup(); + printf("Network start failed!\n"); + return FALSE; + } + + + return TRUE; + } + int FAR PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nCmdShow) { + #ifdef USE_GRAPHCS int i; + #endif WNDCLASS wc; HDC hdc; *************** *** 3426,3434 **** wc.style = CS_VREDRAW | CS_HREDRAW | CS_SAVEBITS | CS_DBLCLKS; wc.lpfnWndProc = AngbandSaverProc; wc.hCursor = NULL; - #if 0 - wc.hIcon = LoadIcon(hInst, MAKEINTATOM(ID_APP)); - #endif wc.lpszMenuName = NULL; wc.lpszClassName = "WindowsScreenSaverClass"; --- 3767,3772 ---- *************** *** 3438,3448 **** } - /* Temporary hooks */ - plog_aux = hack_plog; - quit_aux = hack_quit; - core_aux = hack_core; - /* Prepare the filepaths */ init_stuff(); --- 3776,3781 ---- *************** *** 3451,3457 **** colors16 = (GetDeviceCaps(hdc, BITSPIXEL) == 4); paletted = ((GetDeviceCaps(hdc, RASTERCAPS) & RC_PALETTE) ? TRUE : FALSE); ReleaseDC(NULL, hdc); ! /* Initialize "color_table" */ for (i = 0; i < 16; i++) { --- 3784,3790 ---- colors16 = (GetDeviceCaps(hdc, BITSPIXEL) == 4); paletted = ((GetDeviceCaps(hdc, RASTERCAPS) & RC_PALETTE) ? TRUE : FALSE); ReleaseDC(NULL, hdc); ! #ifdef USE_GRAPHICS /* Initialize "color_table" */ for (i = 0; i < 16; i++) { *************** *** 3463,3486 **** /* Save the "simple" code */ color_table[i][0] = win_pal[i]; } /* Prepare the windows */ init_windows(); - /* Activate hooks */ - plog_aux = hook_plog; - quit_aux = hook_quit; - core_aux = hook_core; - - /* Display the "news" message */ - show_news(); - - /* Allocate and Initialize various arrays */ - init_some_arrays(); - - /* Hack -- assume wizard permissions */ - can_be_wizard = TRUE; - /* Set the system suffix */ ANGBAND_SYS = "win"; --- 3796,3807 ---- /* Save the "simple" code */ color_table[i][0] = win_pal[i]; } + #endif + if (!init_network()) return -1; /*failed to connect */ /* Prepare the windows */ init_windows(); /* Set the system suffix */ ANGBAND_SYS = "win"; *************** *** 3487,3499 **** /* We are now initialized */ initialized = TRUE; ! /* Did the user double click on a save file? */ ! check_for_save_file(lpCmdLine); ! /* Prompt the user */ ! prt("[Choose 'New' or 'Open' from the 'File' menu]", 23, 17); ! Term_fresh(); /* Process messages forever */ while (GetMessage(&msg, NULL, 0, 0)) { --- 3808,3828 ---- /* We are now initialized */ initialized = TRUE; ! /* Initialize some client arrays */ ! init_arrays(); ! /* Initialize the pref files */ ! initalize_all_pref_files(); + /* Setup the key mappings */ + keymap_init(); + + + /* Activate hooks */ + quit_aux = hook_quit; + + Input_loop(); + /* Process messages forever */ while (GetMessage(&msg, NULL, 0, 0)) { *************** *** 3501,3506 **** --- 3830,3837 ---- DispatchMessage(&msg); } + Net_cleanup(); + /* Paranoia */ quit(NULL); *************** *** 3509,3511 **** --- 3840,3846 ---- } #endif /* _Windows */ + + + + Only in mangband-015/src/client: main-x11.o Only in mangband-015/src/client: main-xaw.o diff -c -r -w mangband-015/src/client/netclient.c mangband-021/src/client/netclient.c *** mangband-015/src/client/netclient.c Sun Apr 27 18:00:28 1997 --- mangband-021/src/client/netclient.c Sun May 4 01:56:24 1997 *************** *** 82,87 **** --- 82,90 ---- reliable_tbl[PKT_LINE_INFO] = Receive_line_info; reliable_tbl[PKT_FLOOR] = Receive_floor; reliable_tbl[PKT_MISC_LINE] = Receive_misc_line; + reliable_tbl[PKT_STORE] = Receive_store; + reliable_tbl[PKT_STORE_INFO] = Receive_store_info; + reliable_tbl[PKT_SELL] = Receive_sell; } int Net_setup(void) *************** *** 956,962 **** return n; } ! if (!screen_icky) prt_stat(stat, max, cur); else if ((n = Packet_printf(&qbuf, "%c%c%c%c", ch, stat, max, cur)) <= 0) --- 959,965 ---- return n; } ! if (!screen_icky && !shopping) prt_stat(stat, max, cur); else if ((n = Packet_printf(&qbuf, "%c%c%c%c", ch, stat, max, cur)) <= 0) *************** *** 979,985 **** return n; } ! if (!screen_icky) prt_hp(max, cur); else if ((n = Packet_printf(&qbuf, "%c%hd%hd", ch, max, cur)) <= 0) --- 982,988 ---- return n; } ! if (!screen_icky && !shopping) prt_hp(max, cur); else if ((n = Packet_printf(&qbuf, "%c%hd%hd", ch, max, cur)) <= 0) *************** *** 1001,1007 **** return n; } ! if (!screen_icky) prt_ac(base + plus); else if ((n = Packet_printf(&qbuf, "%c%hd%hd", ch, base, plus)) <= 0) --- 1004,1010 ---- return n; } ! if (!screen_icky && !shopping) prt_ac(base + plus); else if ((n = Packet_printf(&qbuf, "%c%hd%hd", ch, base, plus)) <= 0) *************** *** 1073,1079 **** return n; } ! if (!screen_icky) prt_basic(); else if ((n = Packet_printf(&qbuf, "%c%hd%hd%hd", ch, race, class, sex)) <= 0) --- 1076,1082 ---- return n; } ! if (!screen_icky && !shopping) prt_basic(); else if ((n = Packet_printf(&qbuf, "%c%hd%hd%hd", ch, race, class, sex)) <= 0) *************** *** 1128,1134 **** return n; } ! if (!screen_icky) prt_level(lev, max, cur, adv); else if ((n = Packet_printf(&qbuf, "%c%hu%d%d%d", ch, lev, max, cur, adv)) <= 0) --- 1131,1137 ---- return n; } ! if (!screen_icky && !shopping) prt_level(lev, max, cur, adv); else if ((n = Packet_printf(&qbuf, "%c%hu%d%d%d", ch, lev, max, cur, adv)) <= 0) *************** *** 1150,1156 **** return n; } ! if (!screen_icky) prt_gold(gold); else if ((n = Packet_printf(&qbuf, "%c%d", ch, gold)) <= 0) --- 1153,1168 ---- return n; } ! if (shopping) ! { ! char out_val[64]; ! ! prt("Gold Remaining: ", 19, 53); ! ! sprintf(out_val, "%9ld", (long) gold); ! prt(out_val, 19, 68); ! } ! else if (!screen_icky) prt_gold(gold); else if ((n = Packet_printf(&qbuf, "%c%d", ch, gold)) <= 0) *************** *** 1172,1178 **** return n; } ! if (!screen_icky) prt_sp(max, cur); else if ((n = Packet_printf(&qbuf, "%c%hd%hd", ch, max, cur)) <= 0) --- 1184,1190 ---- return n; } ! if (!screen_icky && !shopping) prt_sp(max, cur); else if ((n = Packet_printf(&qbuf, "%c%hd%hd", ch, max, cur)) <= 0) *************** *** 1212,1218 **** return n; } ! if (!screen_icky) { Term_draw(x, y, a, c); --- 1224,1230 ---- return n; } ! if (!screen_icky && !shopping) { Term_draw(x, y, a, c); *************** *** 1241,1253 **** /* printf("Message: %s\n", buf);*/ ! if (!topline_icky && !screen_icky) { c_msg_print(buf); - - /* Hack -- pause if message is from another player */ - if (buf[0] == '[') - c_msg_print(NULL); } else if ((n = Packet_printf(&qbuf, "%c%s", ch, buf)) <= 0) --- 1253,1261 ---- /* printf("Message: %s\n", buf);*/ ! if (!topline_icky && (shopping || !screen_icky)) { c_msg_print(buf); } else if ((n = Packet_printf(&qbuf, "%c%s", ch, buf)) <= 0) *************** *** 1269,1275 **** return n; } ! if (!screen_icky) prt_state(paralyzed, searching); else if ((n = Packet_printf(&qbuf, "%c%hd%hd", ch, paralyzed, searching)) <= 0) --- 1277,1283 ---- return n; } ! if (!screen_icky && !shopping) prt_state(paralyzed, searching); else if ((n = Packet_printf(&qbuf, "%c%hd%hd", ch, paralyzed, searching)) <= 0) *************** *** 1291,1300 **** return n; } ! if (!screen_icky) prt_title(buf); else ! if ((n = Packet_scanf(&qbuf, "%c%s", ch, buf)) <= 0) { return n; } --- 1299,1308 ---- return n; } ! if (!screen_icky && !shopping) prt_title(buf); else ! if ((n = Packet_printf(&qbuf, "%c%s", ch, buf)) <= 0) { return n; } *************** *** 1313,1319 **** return n; } ! if (!screen_icky) prt_depth(depth); else if ((n = Packet_printf(&qbuf, "%c%hu", ch, depth)) <= 0) --- 1321,1327 ---- return n; } ! if (!screen_icky && !shopping) prt_depth(depth); else if ((n = Packet_printf(&qbuf, "%c%hu", ch, depth)) <= 0) *************** *** 1335,1341 **** return n; } ! if (!screen_icky) prt_confused(confused); else if ((n = Packet_printf(&qbuf, "%c%c", ch, confused)) <= 0) --- 1343,1349 ---- return n; } ! if (!screen_icky && !shopping) prt_confused(confused); else if ((n = Packet_printf(&qbuf, "%c%c", ch, confused)) <= 0) *************** *** 1357,1363 **** return n; } ! if (!screen_icky) prt_poisoned(poison); else if ((n = Packet_printf(&qbuf, "%c%c", ch, poison)) <= 0) --- 1365,1371 ---- return n; } ! if (!screen_icky && !shopping) prt_poisoned(poison); else if ((n = Packet_printf(&qbuf, "%c%c", ch, poison)) <= 0) *************** *** 1379,1385 **** return n; } ! if (!screen_icky) prt_study(study); else if ((n = Packet_printf(&qbuf, "%c%c", ch, study)) <= 0) --- 1387,1393 ---- return n; } ! if (!screen_icky && !shopping) prt_study(study); else if ((n = Packet_printf(&qbuf, "%c%c", ch, study)) <= 0) *************** *** 1401,1407 **** return n; } ! if (!screen_icky) prt_hunger(food); else if ((n = Packet_printf(&qbuf, "%c%hu", ch, food)) <= 0) --- 1409,1415 ---- return n; } ! if (!screen_icky && !shopping) prt_hunger(food); else if ((n = Packet_printf(&qbuf, "%c%hu", ch, food)) <= 0) *************** *** 1423,1429 **** return n; } ! if (!screen_icky) prt_afraid(afraid); else if ((n = Packet_printf(&qbuf, "%c%c", ch, afraid)) <= 0) --- 1431,1437 ---- return n; } ! if (!screen_icky && !shopping) prt_afraid(afraid); else if ((n = Packet_printf(&qbuf, "%c%c", ch, afraid)) <= 0) *************** *** 1445,1451 **** return n; } ! if (!screen_icky) prt_speed(speed); else if ((n = Packet_printf(&qbuf, "%c%hd", ch, speed)) <= 0) --- 1453,1459 ---- return n; } ! if (!screen_icky && !shopping) prt_speed(speed); else if ((n = Packet_printf(&qbuf, "%c%hd", ch, speed)) <= 0) *************** *** 1467,1473 **** return n; } ! if (!screen_icky) prt_cut(cut); else if ((n = Packet_printf(&qbuf, "%c%hd", ch, cut)) <= 0) --- 1475,1481 ---- return n; } ! if (!screen_icky && !shopping) prt_cut(cut); else if ((n = Packet_printf(&qbuf, "%c%hd", ch, cut)) <= 0) *************** *** 1489,1495 **** return n; } ! if (!screen_icky) prt_blind(blind); else if ((n = Packet_printf(&qbuf, "%c%c", ch, blind)) <= 0) --- 1497,1503 ---- return n; } ! if (!screen_icky && !shopping) prt_blind(blind); else if ((n = Packet_printf(&qbuf, "%c%c", ch, blind)) <= 0) *************** *** 1511,1517 **** return n; } ! if (!screen_icky) prt_stun(stun); else if ((n = Packet_printf(&qbuf, "%c%hd", ch, stun)) <= 0) --- 1519,1525 ---- return n; } ! if (!screen_icky && !shopping) prt_stun(stun); else if ((n = Packet_printf(&qbuf, "%c%hd", ch, stun)) <= 0) *************** *** 1580,1586 **** return n; } ! if (!screen_icky && !topline_icky) { /* Ask for a direction */ get_dir(&dir); --- 1588,1594 ---- return n; } ! if (!screen_icky && !topline_icky && !shopping) { /* Ask for a direction */ get_dir(&dir); *************** *** 1637,1642 **** --- 1645,1654 ---- return n; } + /* Check the max line count */ + if (y > last_line_info) + last_line_info = y; + for (x = 0; x < 80; x++) { Packet_scanf(&cbuf, "%c%c", &c, &a); *************** *** 1675,1680 **** --- 1687,1756 ---- return 1; } + int Receive_store(void) + { + int n, price; + char ch, pos, name[1024]; + byte attr; + s16b wgt, num; + + if ((n = Packet_scanf(&cbuf, "%c%c%c%hd%hd%d%s", &ch, &pos, &attr, &wgt, &num, &price, name)) <= 0) + { + return n; + } + + store.stock[pos].sval = attr; + store.stock[pos].weight = wgt; + store.stock[pos].number = num; + store_prices[(int) pos] = price; + strncpy(store_names[(int) pos], name, 80); + + display_inventory(); + + return 1; + } + + int Receive_store_info(void) + { + int n; + char ch; + s16b owner_num, num_items; + + if ((n = Packet_scanf(&cbuf, "%c%hd%hd%hd", &ch, &store_num, &owner_num, &num_items)) <= 0) + { + return n; + } + + store.stock_num = num_items; + store_owner = owners[store_num][owner_num]; + + /* Only enter "display_store" if we're not already shopping */ + if (!shopping) + display_store(); + + return 1; + } + + int Receive_sell(void) + { + int n, price; + char ch, buf[1024]; + + if ((n = Packet_scanf(&cbuf, "%c%d", &ch, &price)) <= 0) + { + return n; + } + + /* Tell the user about the price */ + sprintf(buf, "Accept %d gold? ", price); + + if (get_check(buf)) + Send_store_confirm(); + + return 1; + } + + int Send_search(void) { int n; *************** *** 2054,2059 **** --- 2130,2183 ---- if ((n = Packet_printf(&wbuf, "%c", PKT_MAP)) <= 0) { return n; + } + + return 1; + } + + int Send_store_purchase(int item, int amt) + { + int n; + + if ((n = Packet_printf(&wbuf, "%c%hd%hd", PKT_PURCHASE, item, amt)) <= 0) + { + return n; + } + + return 1; + } + + int Send_store_sell(int item, int amt) + { + int n; + + if ((n = Packet_printf(&wbuf, "%c%hd%hd", PKT_SELL, item, amt)) <= 0) + { + return n; + } + + return 1; + } + + int Send_store_leave(void) + { + int n; + + if ((n = Packet_printf(&wbuf, "%c", PKT_STORE_LEAVE)) <= 0) + { + return n; + } + + return 1; + } + + int Send_store_confirm(void) + { + int n; + + if ((n = Packet_printf(&wbuf, "%c", PKT_STORE_CONFIRM)) <= 0) + { + return n; } return 1; diff -c -r -w mangband-015/src/client/netclient.h mangband-021/src/client/netclient.h *** mangband-015/src/client/netclient.h Sun Apr 27 18:06:49 1997 --- mangband-021/src/client/netclient.h Wed Apr 30 21:05:03 1997 *************** *** 53,56 **** --- 53,59 ---- int Receive_line_info(void); int Receive_floor(void); int Receive_misc_line(void); + int Receive_store(void); + int Receive_store_info(void); + int Receive_sell(void); Only in mangband-015/src/client: netclient.o diff -c -r -w mangband-015/src/client/variable.c mangband-021/src/client/variable.c *** mangband-015/src/client/variable.c Sat Apr 26 14:02:07 1997 --- mangband-021/src/client/variable.c Fri May 2 22:09:40 1997 *************** *** 7,16 **** --- 7,26 ---- object_type inventory[INVEN_TOTAL]; /* The client-side copy of the inventory */ char inventory_name[INVEN_TOTAL][80]; /* The client-side copy of the inventory names */ + store_type store; /* The general info about the current store */ + owner_type store_owner; /* The current owner of the store */ + int store_prices[24]; /* The prices of the items in the store */ + char store_names[24][80]; /* The names of the stuff in the store */ + s16b store_num; /* The current store number */ + char spell_info[9][9][80]; /* Spell information */ setup_t Setup; /* The information given to us by the server */ + bool shopping; /* Are we in a store? */ + + s16b last_line_info; /* Last line of info we've received */ + s16b command_see; s16b command_gap; s16b command_wrk; Only in mangband-015/src/client: variable.o Only in mangband-015/src/client: z-term.o diff -c -r -w mangband-015/src/common/defines.h mangband-021/src/common/defines.h *** mangband-015/src/common/defines.h Mon Apr 28 16:49:12 1997 --- mangband-021/src/common/defines.h Sun May 4 01:53:41 1997 *************** *** 33,43 **** /* ! * Current version number of MAngband: 0.1.5 */ #define VERSION_MAJOR 0 ! #define VERSION_MINOR 1 ! #define VERSION_PATCH 5 /* * This value specifys the suffix to the version info sent to the metaserver. --- 33,43 ---- /* ! * Current version number of MAngband: 0.2.1 */ #define VERSION_MAJOR 0 ! #define VERSION_MINOR 2 ! #define VERSION_PATCH 1 /* * This value specifys the suffix to the version info sent to the metaserver. diff -c -r -w mangband-015/src/common/h-net.h mangband-021/src/common/h-net.h *** mangband-015/src/common/h-net.h Tue Mar 25 15:48:56 1997 --- mangband-021/src/common/h-net.h Tue Apr 29 22:54:43 1997 *************** *** 3,10 **** /* Include the socket buffer library */ #include "sockbuf.h" ! /* Include the socket library for UNIX */ #include "net-unix.h" /* Include the various packet types and error codes */ #include "pack.h" --- 3,18 ---- /* Include the socket buffer library */ #include "sockbuf.h" ! /* Include the socket library for the correct OS */ ! #ifdef WIN32 ! # include "net-win.h" ! #else ! # ifdef MSDOS ! # include "net-ibm.h" ! # else # include "net-unix.h" + # endif + #endif /* Include the various packet types and error codes */ #include "pack.h" diff -c -r -w mangband-015/src/common/h-system.h mangband-021/src/common/h-system.h *** mangband-015/src/common/h-system.h Thu Apr 3 16:47:51 1997 --- mangband-021/src/common/h-system.h Tue Apr 29 17:15:43 1997 *************** *** 55,63 **** --- 55,65 ---- #if defined(WINDOWS) || defined(MSDOS) || defined(USE_EMX) # include + # ifndef WIN32 # include # include # endif + #endif #if !defined(MACINTOSH) && !defined(AMIGA) && \ !defined(ACORN) && !defined(VM) Only in mangband-015/src/common: net-ibm.o Only in mangband-015/src/common: net-unix.o Only in mangband-021/src/common: net-win.c Only in mangband-021/src/common: net-win.h diff -c -r -w mangband-015/src/common/pack.h mangband-021/src/common/pack.h *** mangband-015/src/common/pack.h Sat Apr 26 12:35:16 1997 --- mangband-021/src/common/pack.h Wed Apr 30 20:17:33 1997 *************** *** 52,65 **** #define PKT_SPELL_INFO 48 #define PKT_FLOOR 49 #define PKT_MISC_LINE 50 ! /* Packet types 60-61 are sent from either the client or server */ #define PKT_DIRECTION 60 #define PKT_ITEM 61 ! /* Packet types 70-102 are sent from the client */ #define PKT_WALK 70 #define PKT_RUN 71 #define PKT_TUNNEL 72 --- 52,68 ---- #define PKT_SPELL_INFO 48 #define PKT_FLOOR 49 #define PKT_MISC_LINE 50 + #define PKT_STORE 51 + #define PKT_STORE_INFO 52 ! /* Packet types 60-62 are sent from either the client or server */ #define PKT_DIRECTION 60 #define PKT_ITEM 61 + #define PKT_SELL 62 ! /* Packet types 70-109 are sent from the client */ #define PKT_WALK 70 #define PKT_RUN 71 #define PKT_TUNNEL 72 *************** *** 100,117 **** #define PKT_GAIN 104 #define PKT_GO_UP 105 #define PKT_GO_DOWN 106 ! /* Packet type 150 are hacks */ ! #define PKT_FLUSH 150 ! ! ! /* Packet types 201-202 are more administrative stuff */ #define PKT_FAILURE 121 #define PKT_SUCCESS 122 /* * Possible error codes returned --- 103,122 ---- #define PKT_GAIN 104 #define PKT_GO_UP 105 #define PKT_GO_DOWN 106 + #define PKT_PURCHASE 107 + #define PKT_STORE_LEAVE 108 + #define PKT_STORE_CONFIRM 109 ! /* Packet types 121-122 are more administrative stuff */ #define PKT_FAILURE 121 #define PKT_SUCCESS 122 + /* Packet type 150 are hacks */ + #define PKT_FLUSH 150 + /* * Possible error codes returned diff -c -r -w mangband-015/src/common/sockbuf.c mangband-021/src/common/sockbuf.c *** mangband-015/src/common/sockbuf.c Sun Apr 20 01:28:40 1997 --- mangband-021/src/common/sockbuf.c Tue Apr 29 22:55:00 1997 *************** *** 21,26 **** --- 21,34 ---- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + #ifdef WIN32 + + # include + /* Hack - my errno doesn't include EWOULDBLOCK * - GP */ + # define EWOULDBLOCK WSAEWOULDBLOCK + /* this next one redefines va_start and va_end, but it is necessary -GP*/ + # include + #else # include # include # include *************** *** 31,41 **** #else #include #endif - #ifdef __sgi #include #endif #include "angband.h" #include "version.h" #include "const.h" --- 39,50 ---- # else # include # endif # ifdef __sgi # include # endif + #endif + #include "angband.h" #include "version.h" #include "const.h" *************** *** 47,53 **** --- 56,66 ---- #ifdef MSDOS #include "net-ibm.h" #else + # ifdef WIN32 + # include "net-win.h" + # else # include "net-unix.h" + # endif /* WIN32 */ #endif /* MSDOS */ char net_version[] = VERSION; Only in mangband-015/src/common: sockbuf.o diff -c -r -w mangband-015/src/common/types.h mangband-021/src/common/types.h *** mangband-015/src/common/types.h Sat Apr 26 14:03:06 1997 --- mangband-021/src/common/types.h Wed Apr 30 20:37:24 1997 *************** *** 1034,1040 **** --- 1034,1045 ---- s16b current_star_identify; s16b current_recharge; + s16b current_selling; + s16b current_sell_amt; + int current_sell_price; + int store_num; /* What store this guy is in */ + s16b fast; /* Timed -- Fast */ s16b slow; /* Timed -- Slow */ s16b blind; /* Timed -- Blindness */ Only in mangband-015/src/common: z-form.o Only in mangband-015/src/common: z-rand.o Only in mangband-015/src/common: z-util.o Only in mangband-015/src/common: z-virt.o diff -c -r -w mangband-015/src/server/birth.c mangband-021/src/server/birth.c *** mangband-015/src/server/birth.c Sat Mar 29 15:20:10 1997 --- mangband-021/src/server/birth.c Fri May 2 16:27:27 1997 *************** *** 1211,1230 **** { player_type *p_ptr = Players[Ind]; int y, x, i, d; ! /* Memorize the town */ for (y = 0; y < SCREEN_HGT; y++) { for (x = 0; x < SCREEN_WID; x++) { byte *w_ptr = &p_ptr->cave_flag[y][x]; *w_ptr |= CAVE_MARK; } } /* Place the player correctly in the town */ ! for (i = 0; i < 35; i++) { d = (i + 4) / 35; --- 1211,1235 ---- { player_type *p_ptr = Players[Ind]; int y, x, i, d; + cave_type *c_ptr; + bool dawn = ((turn % (10L * TOWN_DAWN)) < (10L * TOWN_DAWN / 2)); ! /* Memorize the town if it's daytime */ for (y = 0; y < SCREEN_HGT; y++) { for (x = 0; x < SCREEN_WID; x++) { byte *w_ptr = &p_ptr->cave_flag[y][x]; + c_ptr = &cave[0][y][x]; + /* If day or interesting, memorize */ + if (dawn || c_ptr->feat > FEAT_INVIS) *w_ptr |= CAVE_MARK; } } /* Place the player correctly in the town */ ! for (i = 0; i < 175; i++) { d = (i + 4) / 35; *************** *** 1257,1264 **** --- 1262,1282 ---- /* Show him to everybody */ everyone_lite_spot(0, p_ptr->py, p_ptr->px); + /* Hack -- Give him "awareness" of certain objects */ + for (i = 1; i < MAX_K_IDX; i++) + { + object_kind *k_ptr = &k_info[i]; + + /* Skip "empty" objects */ + if (!k_ptr->name) continue; + + /* No flavor yields aware */ + if (!k_ptr->has_flavor) p_ptr->obj_aware[i] = TRUE; + } + /* Set his "current activities" variables */ p_ptr->current_spell = p_ptr->current_rod = p_ptr->current_activation = -1; + p_ptr->current_selling = p_ptr->store_num = -1; /* Set the player's "panel" information */ p_ptr->max_panel_rows = 0; Only in mangband-015/src/server: birth.o diff -c -r -w mangband-015/src/server/cave.c mangband-021/src/server/cave.c *** mangband-015/src/server/cave.c Sun Apr 27 17:45:21 1997 --- mangband-021/src/server/cave.c Fri May 2 23:34:32 1997 *************** *** 1455,1460 **** --- 1455,1467 ---- /* Start a new line */ /*Term_gotoxy(0, y);*/ + /* Clear the old info first */ + for (x = 0; x < 80; x++) + { + p_ptr->scr_info[y][x].c = 0; + p_ptr->scr_info[y][x].a = 0; + } + /* Display the line */ for (x = 0; x < MAP_WID+2; ++x) { *************** *** 1476,1482 **** --- 1483,1496 ---- /* Send that line of info */ Send_line_info(Ind, y); + + /* Throw some nonsense into the "screen_info" so it gets cleared */ + for (x = 0; x < 80; x++) + { + p_ptr->scr_info[y][x].c = 0; + p_ptr->scr_info[y][x].a = 255; } + } /* Player location */ *************** *** 1499,1504 **** --- 1513,1519 ---- */ void do_cmd_view_map(int Ind) { + player_type *p_ptr = Players[Ind]; int cy, cx; /* Enter "icky" mode */ Only in mangband-015/src/server: cave.o diff -c -r -w mangband-015/src/server/cmd1.c mangband-021/src/server/cmd1.c *** mangband-015/src/server/cmd1.c Fri Apr 18 23:35:35 1997 --- mangband-021/src/server/cmd1.c Wed Apr 30 00:28:05 1997 *************** *** 1246,1251 **** --- 1246,1252 ---- /* Hack -- Enter store */ command_new = '_'; + do_cmd_store(Ind); } /* Discover invisible traps */ Only in mangband-015/src/server: cmd1.o Only in mangband-015/src/server: cmd2.o Only in mangband-015/src/server: cmd3.o diff -c -r -w mangband-015/src/server/cmd4.c mangband-021/src/server/cmd4.c *** mangband-015/src/server/cmd4.c Fri Mar 14 14:08:46 1997 --- mangband-021/src/server/cmd4.c Wed Apr 30 17:22:51 1997 *************** *** 306,312 **** forge.name1 = k; /* Describe the artifact */ ! object_desc_store(base_name, &forge, FALSE, 0); } /* Hack -- Build the artifact name */ --- 306,312 ---- forge.name1 = k; /* Describe the artifact */ ! object_desc_store(Ind, base_name, &forge, FALSE, 0); } /* Hack -- Build the artifact name */ Only in mangband-015/src/server: cmd4.o Only in mangband-015/src/server: cmd5.o diff -c -r -w mangband-015/src/server/cmd6.c mangband-021/src/server/cmd6.c *** mangband-015/src/server/cmd6.c Wed Apr 16 12:14:22 1997 --- mangband-021/src/server/cmd6.c Tue Apr 29 13:47:21 1997 *************** *** 2940,2951 **** /* * Hook to determine if an object is activatable */ ! static bool item_tester_hook_activate(object_type *o_ptr) { u32b f1, f2, f3; /* Not known */ ! /*if (!object_known_p(o_ptr)) return (FALSE);*/ /* Extract the flags */ object_flags(o_ptr, &f1, &f2, &f3); --- 2940,2951 ---- /* * Hook to determine if an object is activatable */ ! static bool item_tester_hook_activate(int Ind, object_type *o_ptr) { u32b f1, f2, f3; /* Not known */ ! if (!object_known_p(Ind, o_ptr)) return (FALSE); /* Extract the flags */ object_flags(o_ptr, &f1, &f2, &f3); *************** *** 3096,3104 **** object_type *o_ptr; - /* Prepare the hook */ - item_tester_hook = item_tester_hook_activate; - /* Get the item (in the pack) */ if (item >= 0) { --- 3096,3101 ---- *************** *** 3111,3116 **** --- 3108,3119 ---- o_ptr = &o_list[0 - item]; } + /* Test the item */ + if (!item_tester_hook_activate(Ind, o_ptr)) + { + msg_print(Ind, "You cannot activate that item."); + return; + } /* Take a turn */ p_ptr->energy_use = 100; Only in mangband-015/src/server: cmd6.o diff -c -r -w mangband-015/src/server/dungeon.c mangband-021/src/server/dungeon.c *** mangband-015/src/server/dungeon.c Sun Apr 27 18:06:11 1997 --- mangband-021/src/server/dungeon.c Fri May 2 22:14:57 1997 *************** *** 508,519 **** { /* Get the cave grid */ c_ptr = &cave[Depth][y][x]; /* Darken "boring" features */ if (c_ptr->feat <= FEAT_INVIS) { /* Forget the grid */ ! c_ptr->info &= ~(CAVE_GLOW | CAVE_MARK); /* Hack -- Notice spot */ note_spot(Ind, y, x); --- 508,521 ---- { /* Get the cave grid */ c_ptr = &cave[Depth][y][x]; + w_ptr = &p_ptr->cave_flag[y][x]; /* Darken "boring" features */ if (c_ptr->feat <= FEAT_INVIS) { /* Forget the grid */ ! c_ptr->info &= ~CAVE_GLOW; ! *w_ptr &= ~CAVE_MARK; /* Hack -- Notice spot */ note_spot(Ind, y, x); *************** *** 1438,1445 **** --- 1440,1532 ---- } } + /* + * This function handles "global" things such as the stores, + * day/night in the town, etc. + */ + static void process_various(void) + { + int y, x; + cave_type *c_ptr; + /* If no one is in town, maintain the stores */ + if (players_on_depth[0] == 0) + { + /* Update the stores */ + if (!(turn % (10L * STORE_TURNS))) + { + int n; + /* Maintain each shop (except home) */ + for (n = 0; n < MAX_STORES - 1; n++) + { + /* Maintain */ + store_maint(n); + } + + /* Sometimes, shuffle the shopkeepers */ + if (rand_int(STORE_SHUFFLE) == 0) + { + /* Shuffle a random shop (except home) */ + store_shuffle(rand_int(MAX_STORES - 1)); + } + } + } + + /* Hack -- Daybreak/Nightfall in town */ + if (!(turn % ((10L * TOWN_DAWN) / 2))) + { + bool dawn; + + /* Check for dawn */ + dawn = (!(turn % (10L * TOWN_DAWN))); + + /* Day breaks */ + if (dawn) + { + /* Hack -- Scan the town */ + for (y = 0; y < SCREEN_HGT; y++) + { + for (x = 0; x < SCREEN_WID; x++) + { + /* Get the cave grid */ + c_ptr = &cave[0][y][x]; + + /* Assume lit */ + c_ptr->info |= CAVE_GLOW; + + /* Hack -- Notice spot */ + note_spot_depth(0, y, x); + } + } + } + else + { + /* Hack -- Scan the town */ + for (y = 0; y < SCREEN_HGT; y++) + { + for (x = 0; x < SCREEN_WID; x++) + { + /* Get the cave grid */ + c_ptr = &cave[0][y][x]; + + /* Darken "boring" features */ + if (c_ptr->feat <= FEAT_INVIS) + { + /* Darken the grid */ + c_ptr->info &= ~CAVE_GLOW; + + /* Hack -- Notice spot */ + note_spot_depth(0, y, x); + } + } + } + } + } + } + + + /* * Main loop --KLJ-- * *************** *** 1454,1459 **** --- 1541,1547 ---- { int i, d; byte *w_ptr; + cave_type *c_ptr; /* Check player's depth info */ for (i = 1; i < NumPlayers + 1; i++) *************** *** 1509,1514 **** --- 1597,1604 ---- if (!Depth) { + bool dawn = ((turn % (10L * TOWN_DAWN)) < (10L * TOWN_DAWN / 2)); + p_ptr->max_panel_rows = 0; p_ptr->max_panel_cols = 0; *************** *** 1515,1527 **** p_ptr->cur_hgt = SCREEN_HGT; p_ptr->cur_wid = SCREEN_WID; ! /* Memorize the town for this player */ for (y = 0; y < SCREEN_HGT; y++) { for (x = 0; x < SCREEN_WID; x++) { w_ptr = &p_ptr->cave_flag[y][x]; *w_ptr |= CAVE_MARK; } } --- 1605,1620 ---- p_ptr->cur_hgt = SCREEN_HGT; p_ptr->cur_wid = SCREEN_WID; ! /* Memorize the town for this player (if daytime) */ for (y = 0; y < SCREEN_HGT; y++) { for (x = 0; x < SCREEN_WID; x++) { w_ptr = &p_ptr->cave_flag[y][x]; + c_ptr = &cave[0][y][x]; + /* Memorize if daytime or "interesting" */ + if (dawn || c_ptr->feat > FEAT_INVIS) *w_ptr |= CAVE_MARK; } } *************** *** 1629,1634 **** --- 1722,1730 ---- process_world(i); } + /* Process everything else */ + process_various(); + /* Hack -- Regenerate the monsters every hundred game turns */ if (!(turn % 100)) regen_monsters(); *************** *** 1694,1700 **** */ void play_game(bool new_game) { ! int i; /* Hack -- Character is "icky" */ --- 1790,1796 ---- */ void play_game(bool new_game) { ! int i, n; /* Hack -- Character is "icky" */ *************** *** 1797,1803 **** --- 1893,1912 ---- /* Hack -- enter the world */ turn = 1; + + /* Initialize the stores */ + for (n = 0; n < MAX_STORES; n++) + { + /* Initialize */ + store_init(n); + + /* Ignore home */ + if (n == MAX_STORES - 1) continue; + + /* Maintain the shop */ + for (i = 0; i < 10; i++) store_maint(n); } + } /* Flash a message */ *************** *** 1819,1825 **** /* Reset the visual mappings */ reset_visuals(); - /* Window stuff */ /*p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);*/ --- 1928,1933 ---- Only in mangband-015/src/server: dungeon.o diff -c -r -w mangband-015/src/server/externs.h mangband-021/src/server/externs.h *** mangband-015/src/server/externs.h Tue Apr 22 14:38:24 1997 --- mangband-021/src/server/externs.h Wed Apr 30 20:59:21 1997 *************** *** 532,537 **** --- 532,538 ---- /* load2.c */ extern errr rd_savefile_new(int Ind); + extern errr rd_server_savefile(void); /* melee1.c */ /* melee2.c */ *************** *** 606,611 **** --- 607,615 ---- extern int Send_state(int Ind, bool paralyzed, bool searching); extern int Send_flush(int Ind); extern int Send_line_info(int Ind, int y); + extern int Send_store(int Ind, char pos, byte attr, int wgt, int number, int price, cptr name); + extern int Send_store_info(int Ind, int num, int owner, int items); + extern int Send_store_sell(int Ind, int price); extern void Handle_direction(int Ind, int dir); *************** *** 618,624 **** extern void reset_visuals(void); extern void object_flags(object_type *o_ptr, u32b *f1, u32b *f2, u32b *f3); extern void object_desc(int Ind, char *buf, object_type *o_ptr, int pref, int mode); ! extern void object_desc_store(char *buf, object_type *o_ptr, int pref, int mode); extern bool identify_fully_aux(object_type *o_ptr); extern s16b index_to_label(int i); extern s16b label_to_inven(int Ind, int c); --- 622,628 ---- extern void reset_visuals(void); extern void object_flags(object_type *o_ptr, u32b *f1, u32b *f2, u32b *f3); extern void object_desc(int Ind, char *buf, object_type *o_ptr, int pref, int mode); ! extern void object_desc_store(int Ind, char *buf, object_type *o_ptr, int pref, int mode); extern bool identify_fully_aux(object_type *o_ptr); extern s16b index_to_label(int i); extern s16b label_to_inven(int Ind, int c); *************** *** 781,786 **** --- 785,793 ---- extern bool sleep_monsters_touch(int Ind); /* store.c */ + extern void store_purchase(int Ind, int item, int amt); + extern void store_sell(int Ind, int item, int amt); + extern void store_confirm(int Ind); extern void do_cmd_store(int Ind); extern void store_shuffle(int which); extern void store_maint(int which); diff -c -r -w mangband-015/src/server/files.c mangband-021/src/server/files.c *** mangband-015/src/server/files.c Tue Apr 22 14:40:59 1997 --- mangband-021/src/server/files.c Mon Apr 28 21:18:41 1997 *************** *** 3118,3125 **** */ void exit_game_panic(void) { - int i; - /* If nothing important has happened, just quit */ if (!server_generated || server_saved) quit("panic"); --- 3118,3123 ---- *************** *** 3129,3140 **** /* Clear the top line */ /*prt("", 0, 0);*/ ! for (i = 0; i < NumPlayers; i++) { ! player_type *p_ptr = Players[i]; /* Hack -- turn off some things */ ! disturb(i, 1, 0); /* Mega-Hack -- Delay death */ if (p_ptr->chp < 0) p_ptr->death = FALSE; --- 3127,3138 ---- /* Clear the top line */ /*prt("", 0, 0);*/ ! while (NumPlayers > 0) { ! player_type *p_ptr = Players[1]; /* Hack -- turn off some things */ ! disturb(1, 1, 0); /* Mega-Hack -- Delay death */ if (p_ptr->chp < 0) p_ptr->death = FALSE; *************** *** 3149,3155 **** (void)strcpy(p_ptr->died_from, "(panic save)"); /* Panic save, or get worried */ ! if (!save_player(i)) Destroy_connection(p_ptr->conn, "panic save failed!"); /* Successful panic save */ Destroy_connection(p_ptr->conn, "panic save succeeded!"); --- 3147,3153 ---- (void)strcpy(p_ptr->died_from, "(panic save)"); /* Panic save, or get worried */ ! if (!save_player(1)) Destroy_connection(p_ptr->conn, "panic save failed!"); /* Successful panic save */ Destroy_connection(p_ptr->conn, "panic save succeeded!"); Only in mangband-015/src/server: files.o Only in mangband-015/src/server: generate.o Only in mangband-015/src/server: init1.o Only in mangband-015/src/server: init2.o diff -c -r -w mangband-015/src/server/load2.c mangband-021/src/server/load2.c *** mangband-015/src/server/load2.c Sun Mar 23 13:34:16 1997 --- mangband-021/src/server/load2.c Wed Apr 30 22:38:42 1997 *************** *** 881,887 **** /* * Read the monster lore */ - #if 0 static void rd_lore(int r_idx) { byte tmp8u; --- 881,886 ---- *************** *** 889,894 **** --- 888,894 ---- monster_race *r_ptr = &r_info[r_idx]; + #if 0 /* Pre-2.7.7 */ if (older_than(2, 7, 7)) { *************** *** 932,937 **** --- 932,938 ---- /* Current */ else + #endif { /* Count sights/deaths/kills */ rd_s16b(&r_ptr->r_sights); *************** *** 987,993 **** r_ptr->r_flags5 &= r_ptr->flags5; r_ptr->r_flags6 &= r_ptr->flags6; } - #endif --- 988,993 ---- *************** *** 995,1001 **** /* * Read a store */ - #if 0 static errr rd_store(int n) { store_type *st_ptr = &store[n]; --- 995,1000 ---- *************** *** 1013,1019 **** rd_s16b(&st_ptr->bad_buy); /* Extract the owner (see above) */ ! st_ptr->owner = (older_than(2, 7, 8) ? convert_owner[own] : own); /* Read the items */ for (j = 0; j < num; j++) --- 1012,1018 ---- rd_s16b(&st_ptr->bad_buy); /* Extract the owner (see above) */ ! st_ptr->owner = own; /* Read the items */ for (j = 0; j < num; j++) *************** *** 1034,1043 **** /* Success */ return (0); } - #endif - /* * Read RNG state */ --- 1033,1040 ---- *************** *** 1447,1452 **** --- 1444,1457 ---- /* Hack -- convert old slot numbers */ if (older_than(2, 7, 4)) n = convert_slot(n); + /* Mega-Hack -- Handle artifacts that aren't yet "created" */ + if (artifact_p(&forge)) + { + /* If this artifact isn't created, mark it as created */ + if (!a_info[forge.name1].cur_num) + a_info[forge.name1].cur_num = 1; + } + /* Wield equipment */ if (n >= INVEN_WIELD) { *************** *** 2769,2772 **** --- 2774,2891 ---- return (err); } + errr rd_server_savefile() + { + int i; + + errr err = 0; + + char savefile[1024]; + + byte tmp8u; + u16b tmp16u; + u32b tmp32u; + + /* Savefile name */ + path_build(savefile, 1024, ANGBAND_DIR_SAVE, "server"); + + /* The server savefile is a binary file */ + fff = my_fopen(savefile, "rb"); + + /* Paranoia */ + if (!fff) return (-1); + + /* Strip the version bytes */ + strip_bytes(4); + + /* Hack -- decrypt */ + xor_byte = sf_extra; + + + /* Clear the checksums */ + v_check = 0L; + x_check = 0L; + + + /* Operating system info */ + rd_u32b(&sf_xtra); + + /* Time of savefile creation */ + rd_u32b(&sf_when); + + /* Number of resurrections */ + rd_u16b(&sf_lives); + + /* Number of times played */ + rd_u16b(&sf_saves); + + + /* Later use (always zero) */ + rd_u32b(&tmp32u); + + /* Later use (always zero) */ + rd_u32b(&tmp32u); + + /* Monster Memory */ + rd_u16b(&tmp16u); + + /* Incompatible save files */ + if (tmp16u > MAX_R_IDX) + { + note(format("Too many (%u) monster races!", tmp16u)); + return (21); + } + + /* Read the available records */ + for (i = 0; i < tmp16u; i++) + { + /* Read the lore */ + rd_lore(i); + } + + /* Load the Artifacts */ + rd_u16b(&tmp16u); + + /* Incompatible save files */ + if (tmp16u > MAX_A_IDX) + { + note(format("Too many (%u) artifacts!", tmp16u)); + return (24); + } + + /* Read the artifact flags */ + for (i = 0; i < tmp16u; i++) + { + rd_byte(&tmp8u); + a_info[i].cur_num = tmp8u; + rd_byte(&tmp8u); + rd_byte(&tmp8u); + rd_byte(&tmp8u); + } + + /* Read the stores */ + rd_u16b(&tmp16u); + for (i = 0; i < tmp16u; i++) + { + if (rd_store(i)) return (22); + } + + rd_u32b(&seed_flavor); + rd_u32b(&seed_town); + + rd_s32b(&turn); + + /* Hack -- no ghosts */ + r_info[MAX_R_IDX-1].max_num = 0; + + + /* Check for errors */ + if (ferror(fff)) err = -1; + + /* Close the file */ + my_fclose(fff); + + /* Result */ + return (err); + } Only in mangband-015/src/server: load2.o Only in mangband-015/src/server: main.o Only in mangband-015/src/server: melee1.o diff -c -r -w mangband-015/src/server/melee2.c mangband-021/src/server/melee2.c *** mangband-015/src/server/melee2.c Sun Mar 23 03:35:58 1997 --- mangband-021/src/server/melee2.c Thu May 1 01:39:01 1997 *************** *** 3249,3254 **** --- 3249,3258 ---- if (p_ptr->dun_depth != m_ptr->dun_depth) continue; + /* Hack -- Skip him if he's shopping */ + if (p_ptr->store_num != -1) + continue; + if ((j = distance(p_ptr->px, p_ptr->py, m_ptr->fx, m_ptr->fy)) < dis_to_closest) { dis_to_closest = j; *************** *** 3325,3337 **** } - /* This should be done automagically due to the real time nature */ - - #ifdef SHIMMER_MONSTERS - #if 0 - /* Only when needed, every ten game turns */ ! if (!avoid_other && scan_monsters && (!(turn % 10))) { /* Shimmer multi-hued monsters */ for (i = 1; i < m_max; i++) --- 3329,3336 ---- } /* Only when needed, every ten game turns */ ! if (/*!avoid_other &&*/ scan_monsters /* && (!(turn % 10))*/) { /* Shimmer multi-hued monsters */ for (i = 1; i < m_max; i++) *************** *** 3344,3350 **** if (!m_ptr->r_idx) continue; /* Skip unseen monsters */ ! if (!m_ptr->ml) continue; /* Access the monster race */ r_ptr = &r_info[m_ptr->r_idx]; --- 3343,3349 ---- if (!m_ptr->r_idx) continue; /* Skip unseen monsters */ ! /*if (!m_ptr->ml) continue;*/ /* Access the monster race */ r_ptr = &r_info[m_ptr->r_idx]; *************** *** 3353,3368 **** if (!(r_ptr->flags1 & RF1_ATTR_MULTI)) continue; /* Shimmer Multi-Hued Monsters */ ! lite_spot(m_ptr->fy, m_ptr->fx); } /* Clear the flag */ scan_monsters = FALSE; } - #endif - - #endif - } --- 3352,3363 ---- if (!(r_ptr->flags1 & RF1_ATTR_MULTI)) continue; /* Shimmer Multi-Hued Monsters */ ! everyone_lite_spot(m_ptr->dun_depth, m_ptr->fy, m_ptr->fx); } /* Clear the flag */ scan_monsters = FALSE; } } Only in mangband-015/src/server: melee2.o Only in mangband-015/src/server: monster1.o Only in mangband-015/src/server: monster2.o diff -c -r -w mangband-015/src/server/netserver.c mangband-021/src/server/netserver.c *** mangband-015/src/server/netserver.c Sun Apr 27 17:48:42 1997 --- mangband-021/src/server/netserver.c Sun May 4 04:15:12 1997 *************** *** 102,107 **** --- 102,108 ---- static int MetaSocket = -1; static void Contact(int fd, void *arg); + static void Console(int fd, void *arg); static int Enter_player(char *real, char *name, char *addr, char *host, s16b race, s16b class, s16b sex, unsigned version, int port, int *login_port); *************** *** 199,204 **** --- 200,210 ---- playing_receive[PKT_GO_DOWN] = Receive_go_down; playing_receive[PKT_MESSAGE] = Receive_message; playing_receive[PKT_ITEM] = Receive_item; + playing_receive[PKT_PURCHASE] = Receive_purchase; + + playing_receive[PKT_SELL] = Receive_sell; + playing_receive[PKT_STORE_LEAVE] = Receive_store_leave; + playing_receive[PKT_STORE_CONFIRM] = Receive_store_confirm; } static int Init_setup(void) *************** *** 366,371 **** --- 372,382 ---- } install_input(Contact, Socket, 0); + + #ifdef SERVER_CONSOLE + /* Hack -- Install stdin an the "console" input */ + install_input(Console, 0, 0); + #endif } static int Reply(char *host_addr, int port) *************** *** 413,419 **** --- 424,499 ---- return SUCCESS; } + static void Console(int fd, void *arg) + { + char buf[1024]; + int i; + /* See what we got */ + gets(buf); + + for (i = 0; i < strlen(buf); i++) + { + /* Capitalize each letter */ + buf[i] = toupper(buf[i]); + } + + /* Process our input */ + if (!strncmp(buf, "HELLO", 5)) + s_printf("Hello. How are you?\n"); + + if (!strncmp(buf, "SHUTDOWN", 8)) + { + s_printf("Shutting down.\n"); + + /* Kick every player out and save his game */ + while(NumPlayers > 0) + { + /* Note the we always save the first player */ + player_type *p_ptr = Players[1]; + + /* Indicate cause */ + strcpy(p_ptr->died_from, "server shutdown"); + + /* Try to save */ + if (!save_player(1)) Destroy_connection(p_ptr->conn, "Server shutdown (save failed)"); + + /* Successful save */ + Destroy_connection(p_ptr->conn, "Server shutdown (save succeeded)"); + } + + /* Now wipe every object, to preserve artifacts on the ground */ + for (i = 0; i < MAX_DEPTH; i++) + { + /* Wipe this depth */ + wipe_o_list(i); + } + + /* Save the server state */ + if (!save_server_info()) quit("Server state save failed!"); + + /* Tell the metaserver that we're gone */ + Report_to_meta(META_DIE); + + quit("Server state saved"); + } + + + if (!strncmp(buf, "STATUS", 6)) + { + s_printf("There %s %d %s.\n", (NumPlayers != 1 ? "are" : "is"), NumPlayers, (NumPlayers != 1 ? "players" : "player")); + + if (NumPlayers > 0) + { + s_printf("%s:\n", (NumPlayers > 1 ? "They are" : "He is")); + for (i = 1; i < NumPlayers + 1; i++) + s_printf("\t%s\n", Players[i]->name); + } + } + + + } + static void Contact(int fd, void *arg) { int bytes, reply_to, status, login_port; *************** *** 502,508 **** return status; } ! if (version < 0x0150) { return E_VERSION; } --- 582,588 ---- return status; } ! if (version < 0x0200) { return E_VERSION; } *************** *** 1992,1998 **** --- 2072,2123 ---- return 1; } + int Send_store(int ind, char pos, byte attr, int wgt, int number, int price, cptr name) + { + connection_t *connp = &Conn[Players[ind]->conn]; + if (!BIT(connp->state, CONN_PLAYING | CONN_READY)) + { + errno = 0; + plog(format("Connection not ready for store item (%d.%d.%d)", + ind, connp->state, connp->id)); + return 0; + } + + return Packet_printf(&connp->c, "%c%c%c%hd%hd%d%s", PKT_STORE, pos, attr, wgt, number, price, name); + } + + int Send_store_info(int ind, int num, int owner, int items) + { + connection_t *connp = &Conn[Players[ind]->conn]; + + if (!BIT(connp->state, CONN_PLAYING | CONN_READY)) + { + errno = 0; + plog(format("Connection not ready for store info (%d.%d.%d)", + ind, connp->state, connp->id)); + return 0; + } + + return Packet_printf(&connp->c, "%c%hd%hd%hd", PKT_STORE_INFO, num, owner, items); + } + + int Send_store_sell(int ind, int price) + { + connection_t *connp = &Conn[Players[ind]->conn]; + + if (!BIT(connp->state, CONN_PLAYING | CONN_READY)) + { + errno = 0; + plog(format("Connection not ready for sell price (%d.%d.%d)", + ind, connp->state, connp->id)); + return 0; + } + + return Packet_printf(&connp->c, "%c%d", PKT_SELL, price); + } + + static int Receive_walk(int ind) { connection_t *connp = &Conn[ind]; *************** *** 3002,3008 **** --- 3127,3247 ---- return (TRUE); } + static int Receive_purchase(int ind) + { + connection_t *connp = &Conn[ind]; + char ch; + int n, player; + s16b item, amt; + + if (connp->id != -1) player = GetInd[connp->id]; + else player = 0; + + if ((n = Packet_scanf(&connp->r, "%c%hd%hd", &ch, &item, &amt)) <= 0) + { + if (n == -1) + Destroy_connection(ind, "read error"); + return n; + } + + if (player) + store_purchase(player, item, amt); + + return (TRUE); + } + + static int Receive_sell(int ind) + { + connection_t *connp = &Conn[ind]; + + char ch; + int n, player; + s16b item, amt; + + if (connp->id != -1) player = GetInd[connp->id]; + else player = 0; + + if ((n = Packet_scanf(&connp->r, "%c%hd%hd", &ch, &item, &amt)) <= 0) + { + if (n == -1) + Destroy_connection(ind, "read error"); + return n; + } + + if (player) + store_sell(player, item, amt); + + return (TRUE); + } + + static int Receive_store_leave(int ind) + { + connection_t *connp = &Conn[ind]; + player_type *p_ptr; + + char ch; + int n, player; + + if (connp->id != -1) player = GetInd[connp->id]; + else player = 0; + + if (player) + p_ptr = Players[player]; + + if ((n = Packet_scanf(&connp->r, "%c", &ch)) <= 0) + { + if (n == -1) + Destroy_connection(ind, "read error"); + return n; + } + + if (!player) return (FALSE); + + /* Update stuff */ + p_ptr->update |= (PU_VIEW | PU_LITE); + p_ptr->update |= (PU_MONSTERS); + + /* Redraw stuff */ + p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA); + + /* Redraw map */ + p_ptr->redraw |= (PR_MAP); + + /* Window stuff */ + p_ptr->window |= (PW_OVERHEAD); + + /* Update store info */ + p_ptr->store_num = -1; + + return (TRUE); + } + + static int Receive_store_confirm(int ind) + { + connection_t *connp = &Conn[ind]; + char ch; + int n, player; + + if (connp->id != -1) player = GetInd[connp->id]; + else player = 0; + + if ((n = Packet_scanf(&connp->r, "%c", &ch)) <= 0) + { + if (n == -1) + Destroy_connection(ind, "read error"); + return n; + } + + if (!player) + return (FALSE); + + store_confirm(player); + + return (TRUE); + } + + void Handle_direction(int Ind, int dir) { player_type *p_ptr = Players[Ind]; *************** *** 3031,3038 **** { player_type *p_ptr = Players[Ind]; ! if (p_ptr->current_enchant_h || p_ptr->current_enchant_d || ! p_ptr->current_enchant_a) { enchant_spell_aux(Ind, item, p_ptr->current_enchant_h, p_ptr->current_enchant_d, p_ptr->current_enchant_a); --- 3270,3277 ---- { player_type *p_ptr = Players[Ind]; ! if ((p_ptr->current_enchant_h > 0) || (p_ptr->current_enchant_d > 0) || ! (p_ptr->current_enchant_a > 0)) { enchant_spell_aux(Ind, item, p_ptr->current_enchant_h, p_ptr->current_enchant_d, p_ptr->current_enchant_a); diff -c -r -w mangband-015/src/server/netserver.h mangband-021/src/server/netserver.h *** mangband-015/src/server/netserver.h Sat Apr 26 14:01:22 1997 --- mangband-021/src/server/netserver.h Wed Apr 30 20:48:27 1997 *************** *** 111,117 **** --- 111,122 ---- static int Receive_go_down(int ind); static int Receive_message(int ind); static int Receive_item(int ind); + static int Receive_purchase(int ind); + static int Receive_sell(int ind); + static int Receive_store_leave(int ind); + static int Receive_store_confirm(int ind); + static void Handle_item(int Ind, int item); int Setup_net_server(void); Only in mangband-015/src/server: netserver.o diff -c -r -w mangband-015/src/server/object1.c mangband-021/src/server/object1.c *** mangband-015/src/server/object1.c Sun Mar 23 03:17:52 1997 --- mangband-021/src/server/object1.c Wed Apr 30 17:21:06 1997 *************** *** 1887,1897 **** * Hack -- describe an item currently in a store's inventory * This allows an item to *look* like the player is "aware" of it */ ! void object_desc_store(char *buf, object_type *o_ptr, int pref, int mode) { ! #if 0 /* Save the "aware" flag */ ! bool hack_aware = k_info[o_ptr->k_idx].aware; /* Save the "known" flag */ bool hack_known = (o_ptr->ident & ID_KNOWN) ? TRUE : FALSE; --- 1887,1898 ---- * Hack -- describe an item currently in a store's inventory * This allows an item to *look* like the player is "aware" of it */ ! void object_desc_store(int Ind, char *buf, object_type *o_ptr, int pref, int mode) { ! player_type *p_ptr = Players[Ind]; ! /* Save the "aware" flag */ ! bool hack_aware = p_ptr->obj_aware[o_ptr->k_idx]; /* Save the "known" flag */ bool hack_known = (o_ptr->ident & ID_KNOWN) ? TRUE : FALSE; *************** *** 1901,1919 **** o_ptr->ident |= ID_KNOWN; /* Force "aware" for description */ ! k_info[o_ptr->k_idx].aware = TRUE; /* Describe the object */ ! object_desc(buf, o_ptr, pref, mode); /* Restore "aware" flag */ ! k_info[o_ptr->k_idx].aware = hack_aware; /* Clear the known flag */ if (!hack_known) o_ptr->ident &= ~ID_KNOWN; - #endif } --- 1902,1919 ---- o_ptr->ident |= ID_KNOWN; /* Force "aware" for description */ ! p_ptr->obj_aware[o_ptr->k_idx] = TRUE; /* Describe the object */ ! object_desc(Ind, buf, o_ptr, pref, mode); /* Restore "aware" flag */ ! p_ptr->obj_aware[o_ptr->k_idx] = hack_aware; /* Clear the known flag */ if (!hack_known) o_ptr->ident &= ~ID_KNOWN; } Only in mangband-015/src/server: object1.o diff -c -r -w mangband-015/src/server/object2.c mangband-021/src/server/object2.c *** mangband-015/src/server/object2.c Thu Apr 24 14:26:39 1997 --- mangband-021/src/server/object2.c Wed Apr 30 21:40:25 1997 *************** *** 580,586 **** object_kind *k_ptr = &k_info[o_ptr->k_idx]; /* Aware item -- use template cost */ ! if (object_aware_p(Ind, o_ptr)) return (k_ptr->cost); /* Analyze the type */ switch (o_ptr->tval) --- 580,586 ---- object_kind *k_ptr = &k_info[o_ptr->k_idx]; /* Aware item -- use template cost */ ! if (Ind == 0 || object_aware_p(Ind, o_ptr)) return (k_ptr->cost); /* Analyze the type */ switch (o_ptr->tval) *************** *** 857,863 **** /* Unknown items -- acquire a base value */ ! if (object_known_p(Ind, o_ptr)) { /* Broken items -- worthless */ if (broken_p(o_ptr)) return (0L); --- 857,863 ---- /* Unknown items -- acquire a base value */ ! if (Ind == 0 || object_known_p(Ind, o_ptr)) { /* Broken items -- worthless */ if (broken_p(o_ptr)) return (0L); Only in mangband-015/src/server: object2.o Only in mangband-015/src/server: printout.o diff -c -r -w mangband-015/src/server/save.c mangband-021/src/server/save.c *** mangband-015/src/server/save.c Tue Apr 22 14:41:03 1997 --- mangband-021/src/server/save.c Wed Apr 30 22:37:07 1997 *************** *** 652,663 **** sf_put((v >> 24) & 0xFF); } - #if 0 static void wr_s32b(s32b v) { wr_u32b((u32b)v); } - #endif static void wr_string(cptr str) { --- 652,661 ---- *************** *** 756,762 **** /* * Write a "lore" record */ - #if 0 static void wr_lore(int r_idx) { monster_race *r_ptr = &r_info[r_idx]; --- 754,759 ---- *************** *** 806,812 **** wr_byte(0); wr_byte(0); } - #endif /* --- 803,808 ---- *************** *** 827,833 **** /* * Write a "store" record */ - #if 0 static void wr_store(store_type *st_ptr) { int j; --- 823,828 ---- *************** *** 855,861 **** wr_item(&st_ptr->stock[j]); } } - #endif /* --- 850,855 ---- *************** *** 2561,2572 **** return (FALSE); } bool load_server_info(void) { return (TRUE); } ! bool save_server_info(void) { return (TRUE); } --- 2555,2868 ---- return (FALSE); } + static bool wr_server_savefile(void) + { + int i; + + u32b now; + + byte tmp8u; + u16b tmp16u; + + + /* Guess at the current time */ + now = time((time_t *)0); + + + /* Note the operating system */ + sf_xtra = 0L; + + /* Note when the file was saved */ + sf_when = now; + + /* Note the number of saves */ + sf_saves++; + + + /*** Actually write the file ***/ + + /* Dump the file header */ + xor_byte = 0; + wr_byte(VERSION_MAJOR); + xor_byte = 0; + wr_byte(VERSION_MINOR); + xor_byte = 0; + wr_byte(VERSION_PATCH); + xor_byte = 0; + tmp8u = rand_int(256); + wr_byte(tmp8u); + + + /* Reset the checksum */ + v_stamp = 0L; + x_stamp = 0L; + + + /* Operating system */ + wr_u32b(sf_xtra); + + + /* Time file last saved */ + wr_u32b(sf_when); + + /* Number of past lives */ + wr_u16b(sf_lives); + + /* Number of times saved */ + wr_u16b(sf_saves); + + /* Space */ + wr_u32b(0L); + wr_u32b(0L); + + /* Dump the monster (unique) lore */ + tmp16u = MAX_R_IDX; + wr_u16b(tmp16u); + for (i = 0; i < tmp16u; i++) wr_lore(i); + + /* Hack -- Dump the artifacts */ + tmp16u = MAX_A_IDX; + wr_u16b(tmp16u); + for (i = 0; i < tmp16u; i++) + { + artifact_type *a_ptr = &a_info[i]; + wr_byte(a_ptr->cur_num); + wr_byte(0); + wr_byte(0); + wr_byte(0); + } + + + /* Note the stores */ + tmp16u = MAX_STORES; + wr_u16b(tmp16u); + + /* Dump the stores */ + for (i = 0; i < tmp16u; i++) wr_store(&store[i]); + + + wr_u32b(seed_flavor); + wr_u32b(seed_town); + + wr_s32b(turn); + + /* Error in save */ + if (ferror(fff) || (fflush(fff) == EOF)) return FALSE; + + /* Successful save */ + return TRUE; + } + + + static bool save_server_aux(char *name) + { + bool ok = FALSE; + + int fd = -1; + + int mode = 0644; + + + /* No file yet */ + fff = NULL; + + + /* File type is "SAVE" */ + FILE_TYPE(FILE_TYPE_SAVE); + + + /* Create the savefile */ + fd = fd_make(name, mode); + + /* File is okay */ + if (fd >= 0) + { + /* Close the "fd" */ + (void)fd_close(fd); + + /* Open the savefile */ + fff = my_fopen(name, "wb"); + + /* Successful open */ + if (fff) + { + /* Write the savefile */ + if (wr_server_savefile()) ok = TRUE; + + /* Attempt to close it */ + if (my_fclose(fff)) ok = FALSE; + } + + /* Remove "broken" files */ + if (!ok) (void)fd_kill(name); + } + + + /* Failure */ + if (!ok) return (FALSE); + + /* Successful save */ + server_saved = TRUE; + + /* Success */ + return (TRUE); + } + + + /* + * Load the server info (artifacts created and uniques killed) + * from a special savefile. + */ bool load_server_info(void) { + int fd = -1; + + byte vvv[4]; + + errr err = 0; + + cptr what = "generic"; + + char buf[1024]; + + path_build(buf, 1024, ANGBAND_DIR_SAVE, "server"); + + #if !defined(MACINTOSH) && !defined(WINDOWS) && !defined(VM) + + /* XXX XXX XXX Fix this */ + if (access(buf, 0) < 0) + { + /* Give message */ + s_printf("Server savefile does not exist\n"); + + /* Allow this */ return (TRUE); } ! #endif ! ! /* Okay */ ! if (!err) { + /* Open the savefile */ + fd = fd_open(buf, O_RDONLY); + + /* No file */ + if (fd < 0) err = -1; + + /* Message (below) */ + if (err) what = "Cannot open savefile"; + } + + /* Process file */ + if (!err) + { + /* Read the first four bytes */ + if (fd_read(fd, (char*)(vvv), 4)) err = -1; + + /* What */ + if (err) what = "Cannot read savefile"; + + /* Close the file */ + (void)fd_close(fd); + } + + /* Process file */ + if (!err) + { + /* Extract version */ + sf_major = vvv[0]; + sf_minor = vvv[1]; + sf_patch = vvv[2]; + sf_extra = vvv[3]; + + /* Parse "MAngband" savefiles */ + if (sf_major == 0) + { + /* Attempt to load */ + err = rd_server_savefile(); + } + + /* Parse "future" savefiles */ + else + { + /* Error XXX XXX XXX */ + err = -1; + } + + /* Message (below) */ + if (err) what = "Cannot parse savefile"; + } + + /* Okay */ + if (!err) + { + /* Give a conversion warning */ + if ((version_major != sf_major) || + (version_minor != sf_minor) || + (version_patch != sf_patch)) + { + /* Message */ + printf("Converted a %d.%d.%d savefile.\n", + sf_major, sf_minor, sf_patch); + } + + /* The server state was loaded */ + server_state_loaded = TRUE; + + /* Success */ return (TRUE); + } + + /* Message */ + s_printf("Error (%s) reading a %d.%d.%d server savefile.", what, sf_major, sf_minor, sf_patch); + + return (FALSE); + } + + + /* + * Save the server state to a "server" savefile. + */ + bool save_server_info(void) + { + int result = FALSE; + char safe[1024]; + + /* New savefile */ + path_build(safe, 1024, ANGBAND_DIR_SAVE, "server.new"); + + /* Remove it */ + fd_kill(safe); + + /* Attempt to save the server state */ + if (save_server_aux(safe)) + { + char temp[1024]; + char prev[1024]; + + /* Old savefile */ + path_build(temp, 1024, ANGBAND_DIR_SAVE, "server.old"); + + /* Remove it */ + fd_kill(temp); + + /* Name of previous savefile */ + path_build(prev, 1024, ANGBAND_DIR_SAVE, "server"); + + /* Preserve old savefile */ + fd_move(prev, temp); + + /* Activate new savefile */ + fd_move(safe, prev); + + /* Remove preserved savefile */ + fd_kill(temp); + + /* Success */ + result = TRUE; + } + + /* Return the result */ + return (result); } Only in mangband-015/src/server: save.o Only in mangband-015/src/server: sched.o diff -c -r -w mangband-015/src/server/spells1.c mangband-021/src/server/spells1.c *** mangband-015/src/server/spells1.c Mon Apr 28 16:26:11 1997 --- mangband-021/src/server/spells1.c Sun May 4 04:25:22 1997 *************** *** 2129,2135 **** if (do_kill) { /* Effect "observed" */ ! if (p_ptr->obj_vis[c_ptr->o_idx]) { obvious = TRUE; object_desc(Ind, o_name, o_ptr, FALSE, 0); --- 2129,2135 ---- if (do_kill) { /* Effect "observed" */ ! if (!quiet && p_ptr->obj_vis[c_ptr->o_idx]) { obvious = TRUE; object_desc(Ind, o_name, o_ptr, FALSE, 0); Only in mangband-015/src/server: spells1.o Only in mangband-015/src/server: spells2.o diff -c -r -w mangband-015/src/server/store.c mangband-021/src/server/store.c *** mangband-015/src/server/store.c Sun Mar 23 03:44:22 1997 --- mangband-021/src/server/store.c Wed Apr 30 23:23:43 1997 *************** *** 18,24 **** #define MAX_COMMENT_1 6 - #if 0 static cptr comment_1[MAX_COMMENT_1] = { "Okay.", --- 18,23 ---- *************** *** 29,34 **** --- 28,35 ---- "Taken!" }; + #if 0 + #define MAX_COMMENT_2A 2 static cptr comment_2a[MAX_COMMENT_2A] = *************** *** 126,146 **** "Sorry, what was that again?" }; /* * Successful haggle. */ ! static void say_comment_1(void) { ! msg_print(comment_1[rand_int(MAX_COMMENT_1)]); } /* * Continue haggling (player is buying) */ ! static void say_comment_2(s32b value, int annoyed) { char tmp_val[80]; --- 127,149 ---- "Sorry, what was that again?" }; + #endif /* * Successful haggle. */ ! static void say_comment_1(int Ind) { ! msg_print(Ind, comment_1[rand_int(MAX_COMMENT_1)]); } + #if 0 /* * Continue haggling (player is buying) */ ! static void say_comment_2(int Ind, s32b value, int annoyed) { char tmp_val[80]; *************** *** 151,157 **** if (annoyed > 0) { /* Formatted message */ ! msg_format(comment_2a[rand_int(MAX_COMMENT_2A)], tmp_val); } /* Normal offer */ --- 154,160 ---- if (annoyed > 0) { /* Formatted message */ ! msg_format(Ind, comment_2a[rand_int(MAX_COMMENT_2A)], tmp_val); } /* Normal offer */ *************** *** 158,164 **** else { /* Formatted message */ ! msg_format(comment_2b[rand_int(MAX_COMMENT_2B)], tmp_val); } } --- 161,167 ---- else { /* Formatted message */ ! msg_format(Ind, comment_2b[rand_int(MAX_COMMENT_2B)], tmp_val); } } *************** *** 166,172 **** /* * Continue haggling (player is selling) */ ! static void say_comment_3(s32b value, int annoyed) { char tmp_val[80]; --- 169,175 ---- /* * Continue haggling (player is selling) */ ! static void say_comment_3(int Ind, s32b value, int annoyed) { char tmp_val[80]; *************** *** 177,183 **** if (annoyed > 0) { /* Formatted message */ ! msg_format(comment_3a[rand_int(MAX_COMMENT_3A)], tmp_val); } /* Normal offer */ --- 180,186 ---- if (annoyed > 0) { /* Formatted message */ ! msg_format(Ind, comment_3a[rand_int(MAX_COMMENT_3A)], tmp_val); } /* Normal offer */ *************** *** 184,190 **** else { /* Formatted message */ ! msg_format(comment_3b[rand_int(MAX_COMMENT_3B)], tmp_val); } } --- 187,193 ---- else { /* Formatted message */ ! msg_format(Ind, comment_3b[rand_int(MAX_COMMENT_3B)], tmp_val); } } *************** *** 192,201 **** /* * Kick 'da bum out. -RAK- */ ! static void say_comment_4(void) { ! msg_print(comment_4a[rand_int(MAX_COMMENT_4A)]); ! msg_print(comment_4b[rand_int(MAX_COMMENT_4B)]); } --- 195,204 ---- /* * Kick 'da bum out. -RAK- */ ! static void say_comment_4(int Ind) { ! msg_print(Ind, comment_4a[rand_int(MAX_COMMENT_4A)]); ! msg_print(Ind, comment_4b[rand_int(MAX_COMMENT_4B)]); } *************** *** 202,210 **** /* * You are insulting me */ ! static void say_comment_5(void) { ! msg_print(comment_5[rand_int(MAX_COMMENT_5)]); } --- 205,213 ---- /* * You are insulting me */ ! static void say_comment_5(int Ind) { ! msg_print(Ind, comment_5[rand_int(MAX_COMMENT_5)]); } *************** *** 211,219 **** /* * That makes no sense. */ ! static void say_comment_6(void) { ! msg_print(comment_6[rand_int(5)]); } --- 214,222 ---- /* * That makes no sense. */ ! static void say_comment_6(int Ind) { ! msg_print(Ind, comment_6[rand_int(5)]); } *************** *** 262,267 **** --- 265,271 ---- "The shopkeeper smiles gleefully." }; + /* * Let a shop-keeper React to a purchase * *************** *** 297,303 **** #endif - /* * We store the current "store number" here so everyone can access it */ --- 301,306 ---- *************** *** 312,330 **** /* * We store the current "store pointer" here so everyone can access it */ ! static store_type *st_ptr = NULL; /* * We store the current "owner type" here so everyone can access it */ ! static owner_type *ot_ptr = NULL; - #if 0 - /* * Buying and selling adjustments for race combinations. * Entry[owner][player] gives the basic "cost inflation". --- 315,331 ---- /* * We store the current "store pointer" here so everyone can access it */ ! /*static store_type *st_ptr = NULL;*/ /* * We store the current "owner type" here so everyone can access it */ ! /*static owner_type *ot_ptr = NULL;*/ /* * Buying and selling adjustments for race combinations. * Entry[owner][player] gives the basic "cost inflation". *************** *** 387,394 **** * to adjust (by 200) to extract a usable multiplier. Note that the * "greed" value is always something (?). */ ! static s32b price_item(object_type *o_ptr, int greed, bool flip) { int factor; int adjust; s32b price; --- 388,397 ---- * to adjust (by 200) to extract a usable multiplier. Note that the * "greed" value is always something (?). */ ! static s32b price_item(int Ind, object_type *o_ptr, int greed, bool flip) { + player_type *p_ptr = Players[Ind]; + owner_type *ot_ptr = &owners[p_ptr->store_num][store[p_ptr->store_num].owner]; int factor; int adjust; s32b price; *************** *** 395,401 **** /* Get the value of one of the items */ ! price = object_value(o_ptr); /* Worthless items */ if (price <= 0) return (0L); --- 398,404 ---- /* Get the value of one of the items */ ! price = object_value(Ind, o_ptr); /* Worthless items */ if (price <= 0) return (0L); *************** *** 418,424 **** if (adjust > 100) adjust = 100; /* Mega-Hack -- Black market sucks */ ! if (store_num == 6) price = price / 2; } /* Shop is selling */ --- 421,427 ---- if (adjust > 100) adjust = 100; /* Mega-Hack -- Black market sucks */ ! if (p_ptr->store_num == 6) price = price / 2; } /* Shop is selling */ *************** *** 431,437 **** if (adjust < 100) adjust = 100; /* Mega-Hack -- Black market sucks */ ! if (store_num == 6) price = price * 2; } /* Compute the final price (with rounding) */ --- 434,440 ---- if (adjust < 100) adjust = 100; /* Mega-Hack -- Black market sucks */ ! if (p_ptr->store_num == 6) price = price * 2; } /* Compute the final price (with rounding) */ *************** *** 443,449 **** /* Return the price */ return (price); } - #endif /* --- 446,451 ---- *************** *** 463,473 **** */ static void mass_produce(object_type *o_ptr) { - #if 0 int size = 1; int discount = 0; ! s32b cost = object_value(o_ptr); /* Analyze the type */ --- 465,474 ---- */ static void mass_produce(object_type *o_ptr) { int size = 1; int discount = 0; ! s32b cost = object_value(0, o_ptr); /* Analyze the type */ *************** *** 560,566 **** /* Save the total pile size */ o_ptr->number = size - (size * discount / 100); - #endif } --- 561,566 ---- *************** *** 636,650 **** * Note that the shop, just like a player, will not accept things * it cannot hold. Before, one could "nuke" potions this way. */ ! #if 0 ! static bool store_check_num(object_type *o_ptr) { int i; object_type *j_ptr; /* Free space is always usable */ if (st_ptr->stock_num < st_ptr->stock_size) return TRUE; /* The "home" acts like the player */ if (store_num == 7) { --- 636,651 ---- * Note that the shop, just like a player, will not accept things * it cannot hold. Before, one could "nuke" potions this way. */ ! static bool store_check_num(int st, object_type *o_ptr) { int i; object_type *j_ptr; + store_type *st_ptr = &store[st]; /* Free space is always usable */ if (st_ptr->stock_num < st_ptr->stock_size) return TRUE; + #if 0 /* The "home" acts like the player */ if (store_num == 7) { *************** *** 658,663 **** --- 659,665 ---- if (object_similar(j_ptr, o_ptr)) return (TRUE); } } + #endif /* Normal stores do special stuff */ else *************** *** 685,697 **** * * Note that a shop-keeper must refuse to buy "worthless" items */ ! static bool store_will_buy(object_type *o_ptr) { /* Hack -- The Home is simple */ ! if (store_num == 7) return (TRUE); /* Switch on the store */ ! switch (store_num) { /* General Store */ case 0: --- 687,701 ---- * * Note that a shop-keeper must refuse to buy "worthless" items */ ! static bool store_will_buy(int Ind, object_type *o_ptr) { + player_type *p_ptr = Players[Ind]; + /* Hack -- The Home is simple */ ! if (p_ptr->store_num == 7) return (TRUE); /* Switch on the store */ ! switch (p_ptr->store_num) { /* General Store */ case 0: *************** *** 813,819 **** } /* XXX XXX XXX Ignore "worthless" items */ ! if (object_value(o_ptr) <= 0) return (FALSE); /* Assume okay */ return (TRUE); --- 817,823 ---- } /* XXX XXX XXX Ignore "worthless" items */ ! if (object_value(Ind, o_ptr) <= 0) return (FALSE); /* Assume okay */ return (TRUE); *************** *** 831,836 **** --- 835,841 ---- * Also note that it may not correctly "adapt" to "knowledge" bacoming * known, the player may have to pick stuff up and drop it again. */ + #if 0 static int home_carry(object_type *o_ptr) { int slot; *************** *** 927,942 **** * * In all cases, return the slot (or -1) where the object was placed */ ! static int store_carry(object_type *o_ptr) { - #if 0 int i, slot; s32b value, j_value; object_type *j_ptr; /* Evaluate the object */ ! value = object_value(o_ptr); /* Cursed/Worthless items "disappear" when sold */ if (value <= 0) return (-1); --- 932,947 ---- * * In all cases, return the slot (or -1) where the object was placed */ ! static int store_carry(int st, object_type *o_ptr) { int i, slot; s32b value, j_value; object_type *j_ptr; + store_type *st_ptr = &store[st]; /* Evaluate the object */ ! value = object_value(0, o_ptr); /* Cursed/Worthless items "disappear" when sold */ if (value <= 0) return (-1); *************** *** 981,987 **** if (o_ptr->sval > j_ptr->sval) continue; /* Evaluate that slot */ ! j_value = object_value(j_ptr); /* Objects sort by decreasing value */ if (value > j_value) break; --- 986,992 ---- if (o_ptr->sval > j_ptr->sval) continue; /* Evaluate that slot */ ! j_value = object_value(0, j_ptr); /* Objects sort by decreasing value */ if (value > j_value) break; *************** *** 1002,1008 **** /* Return the location */ return (slot); - #endif } --- 1007,1012 ---- *************** *** 1010,1019 **** * Increase, by a given amount, the number of a certain item * in a certain store. This can result in zero items. */ ! static void store_item_increase(int item, int num) { int cnt; object_type *o_ptr; /* Get the item */ o_ptr = &st_ptr->stock[item]; --- 1014,1024 ---- * Increase, by a given amount, the number of a certain item * in a certain store. This can result in zero items. */ ! static void store_item_increase(int st, int item, int num) { int cnt; object_type *o_ptr; + store_type *st_ptr = &store[st]; /* Get the item */ o_ptr = &st_ptr->stock[item]; *************** *** 1032,1041 **** /* * Remove a slot if it is empty */ ! static void store_item_optimize(int item) { int j; object_type *o_ptr; /* Get the item */ o_ptr = &st_ptr->stock[item]; --- 1037,1047 ---- /* * Remove a slot if it is empty */ ! static void store_item_optimize(int st, int item) { int j; object_type *o_ptr; + store_type *st_ptr = &store[st]; /* Get the item */ o_ptr = &st_ptr->stock[item]; *************** *** 1100,1107 **** * Hack -- we attempt to "maintain" piles of items when possible. */ ! static void store_delete(void) { int what, num; /* Pick a random slot */ --- 1106,1114 ---- * Hack -- we attempt to "maintain" piles of items when possible. */ ! static void store_delete(int st) { + store_type *st_ptr = &store[st]; int what, num; /* Pick a random slot */ *************** *** 1116,1124 **** /* Hack -- sometimes, only destroy a single item */ if (rand_int(100) < 50) num = 1; /* Actually destroy (part of) the item */ ! store_item_increase(what, -num); ! store_item_optimize(what); } --- 1123,1138 ---- /* Hack -- sometimes, only destroy a single item */ if (rand_int(100) < 50) num = 1; + /* Hack -- preserve artifacts */ + if (artifact_p(&st_ptr->stock[what])) + { + /* Preserve this one */ + a_info[st_ptr->stock[what].name1].cur_num = 0; + } + /* Actually destroy (part of) the item */ ! store_item_increase(st, what, -num); ! store_item_optimize(st, what); } *************** *** 1133,1141 **** * * Should we check for "permission" to have the given item? */ ! static void store_create(void) { ! #if 0 int i, tries, level; object_type tmp_obj; object_type *o_ptr = &tmp_obj; --- 1147,1155 ---- * * Should we check for "permission" to have the given item? */ ! static void store_create(int st) { ! store_type *st_ptr = &store[st]; int i, tries, level; object_type tmp_obj; object_type *o_ptr = &tmp_obj; *************** *** 1199,1205 **** if (black_market_crap(o_ptr)) continue; /* Hack -- No "cheap" items */ ! if (object_value(o_ptr) < 10) continue; /* No "worthless" items */ /* if (object_value(o_ptr) <= 0) continue; */ --- 1213,1219 ---- if (black_market_crap(o_ptr)) continue; /* Hack -- No "cheap" items */ ! if (object_value(0, o_ptr) < 10) continue; /* No "worthless" items */ /* if (object_value(o_ptr) <= 0) continue; */ *************** *** 1209,1215 **** else { /* No "worthless" items */ ! if (object_value(o_ptr) <= 0) continue; } --- 1223,1229 ---- else { /* No "worthless" items */ ! if (object_value(0, o_ptr) <= 0) continue; } *************** *** 1217,1228 **** mass_produce(o_ptr); /* Attempt to carry the (known) item */ ! (void)store_carry(o_ptr); /* Definitely done */ break; } - #endif } --- 1231,1241 ---- mass_produce(o_ptr); /* Attempt to carry the (known) item */ ! (void)store_carry(st, o_ptr); /* Definitely done */ break; } } *************** *** 1230,1238 **** /* * Eliminate need to bargain if player has haggled well in the past */ - #if 0 static bool noneedtobargain(s32b minprice) { s32b good = st_ptr->good_buy; s32b bad = st_ptr->bad_buy; --- 1243,1254 ---- /* * Eliminate need to bargain if player has haggled well in the past */ static bool noneedtobargain(s32b minprice) { + /* Hack -- We never haggle anyway --KLJ-- */ + return (TRUE); + + #if 0 s32b good = st_ptr->good_buy; s32b bad = st_ptr->bad_buy; *************** *** 1247,1252 **** --- 1263,1269 ---- /* Return the flag */ return (FALSE); + #endif } *************** *** 1253,1258 **** --- 1270,1276 ---- /* * Update the bargain info */ + #if 0 static void updatebargain(s32b price, s32b minprice) { /* Hack -- auto-haggle */ *************** *** 1281,1307 **** } } } /* * Re-displays a single store entry */ ! static void display_entry(int pos) { ! int i; object_type *o_ptr; s32b x; char o_name[80]; ! char out_val[160]; - int maxwid = 75; /* Get the item */ o_ptr = &st_ptr->stock[pos]; /* Get the "offset" */ i = (pos % 12); --- 1299,1332 ---- } } } + #endif /* * Re-displays a single store entry + * + * Actually re-sends a single store entry --KLJ-- */ ! static void display_entry(int Ind, int pos) { ! player_type *p_ptr = Players[Ind]; ! store_type *st_ptr = &store[p_ptr->store_num]; ! owner_type *ot_ptr = &owners[p_ptr->store_num][st_ptr->owner]; ! object_type *o_ptr; s32b x; char o_name[80]; ! byte attr; ! int wgt; int maxwid = 75; /* Get the item */ o_ptr = &st_ptr->stock[pos]; + #if 0 /* Get the "offset" */ i = (pos % 12); *************** *** 1308,1336 **** /* Label it, clear the line --(-- */ (void)sprintf(out_val, "%c) ", I2A(i)); prt(out_val, i+6, 0); /* Describe an item in the home */ ! if (store_num == 7) { maxwid = 75; /* Leave room for weights, if necessary -DRS- */ ! if (show_weights) maxwid -= 10; /* Describe the object */ ! object_desc(o_name, o_ptr, TRUE, 3); o_name[maxwid] = '\0'; ! c_put_str(tval_to_attr[o_ptr->tval], o_name, i+6, 3); ! /* Show weights */ ! if (show_weights) ! { /* Only show the weight of an individual item */ ! int wgt = o_ptr->weight; ! (void)sprintf(out_val, "%3d.%d lb", wgt / 10, wgt % 10); ! put_str(out_val, i+6, 68); } - } /* Describe an item (fully) in a store */ else --- 1333,1361 ---- /* Label it, clear the line --(-- */ (void)sprintf(out_val, "%c) ", I2A(i)); prt(out_val, i+6, 0); + #endif /* Describe an item in the home */ ! if (p_ptr->store_num == 7) { maxwid = 75; /* Leave room for weights, if necessary -DRS- */ ! /*if (show_weights) maxwid -= 10;*/ /* Describe the object */ ! object_desc(Ind, o_name, o_ptr, TRUE, 3); o_name[maxwid] = '\0'; ! /*c_put_str(tval_to_attr[o_ptr->tval], o_name, i+6, 3);*/ ! attr = tval_to_attr[o_ptr->tval]; ! /* Only show the weight of an individual item */ ! wgt = o_ptr->weight; ! ! /* Send the info */ ! Send_store(Ind, pos, attr, wgt, o_ptr->number, 0, o_name); } /* Describe an item (fully) in a store */ else *************** *** 1339,1417 **** maxwid = 65; /* Leave room for weights, if necessary -DRS- */ ! if (show_weights) maxwid -= 7; /* Describe the object (fully) */ ! object_desc_store(o_name, o_ptr, TRUE, 3); o_name[maxwid] = '\0'; ! c_put_str(tval_to_attr[o_ptr->tval], o_name, i+6, 3); ! /* Show weights */ ! if (show_weights) ! { /* Only show the weight of an individual item */ ! int wgt = o_ptr->weight; ! (void)sprintf(out_val, "%3d.%d", wgt / 10, wgt % 10); ! put_str(out_val, i+6, 61); ! } - /* Display a "fixed" cost */ - if (o_ptr->ident & ID_FIXED) - { /* Extract the "minimum" price */ ! x = price_item(o_ptr, ot_ptr->min_inflate, FALSE); ! /* Actually draw the price (not fixed) */ ! (void)sprintf(out_val, "%9ld F", (long)x); ! put_str(out_val, i+6, 68); } - - /* Display a "taxed" cost */ - else if (auto_haggle) - { - /* Extract the "minimum" price */ - x = price_item(o_ptr, ot_ptr->min_inflate, FALSE); - - /* Hack -- Apply Sales Tax if needed */ - if (!noneedtobargain(x)) x += x / 10; - - /* Actually draw the price (with tax) */ - (void)sprintf(out_val, "%9ld ", (long)x); - put_str(out_val, i+6, 68); } - /* Display a "haggle" cost */ - else - { - /* Extrect the "maximum" price */ - x = price_item(o_ptr, ot_ptr->max_inflate, FALSE); - /* Actually draw the price (not fixed) */ - (void)sprintf(out_val, "%9ld ", (long)x); - put_str(out_val, i+6, 68); - } - } - } - - /* * Displays a store's inventory -RAK- * All prices are listed as "per individual object". -BEN- */ ! static void display_inventory(void) { ! int i, k; ! /* Display the next 12 items */ ! for (k = 0; k < 12; k++) { /* Do not display "dead" items */ ! if (store_top + k >= st_ptr->stock_num) break; /* Display that line */ ! display_entry(store_top + k); } /* Erase the extra lines and the "more" prompt */ for (i = k; i < 13; i++) prt("", i + 6, 0); --- 1364,1413 ---- maxwid = 65; /* Leave room for weights, if necessary -DRS- */ ! /*if (show_weights) maxwid -= 7;*/ /* Describe the object (fully) */ ! object_desc_store(Ind, o_name, o_ptr, TRUE, 3); o_name[maxwid] = '\0'; ! /*c_put_str(tval_to_attr[o_ptr->tval], o_name, i+6, 3);*/ ! attr = tval_to_attr[o_ptr->tval]; ! /* Only show the weight of an individual item */ ! wgt = o_ptr->weight; /* Extract the "minimum" price */ ! x = price_item(Ind, o_ptr, ot_ptr->min_inflate, FALSE); ! /* Send the info */ ! Send_store(Ind, pos, attr, wgt, o_ptr->number, x, o_name); } } /* * Displays a store's inventory -RAK- * All prices are listed as "per individual object". -BEN- + * + * The inventory is "sent" not "displayed". -KLJ- */ ! static void display_inventory(int Ind) { ! player_type *p_ptr = Players[Ind]; ! store_type *st_ptr = &store[p_ptr->store_num]; ! int k; ! /* Display the next 24 items */ ! for (k = 0; k < 24; k++) { /* Do not display "dead" items */ ! if (k >= st_ptr->stock_num) break; /* Display that line */ ! display_entry(Ind, k); } + #if 0 /* Erase the extra lines and the "more" prompt */ for (i = k; i < 13; i++) prt("", i + 6, 0); *************** *** 1427,1432 **** --- 1423,1429 ---- /* Indicate the "current page" */ put_str(format("(Page %d)", store_top/12 + 1), 5, 20); } + #endif } *************** *** 1433,1446 **** /* * Displays players gold -RAK- */ ! static void store_prt_gold(void) { ! char out_val[64]; ! prt("Gold Remaining: ", 19, 53); ! ! sprintf(out_val, "%9ld", (long)p_ptr->au); ! prt(out_val, 19, 68); } --- 1430,1440 ---- /* * Displays players gold -RAK- */ ! static void store_prt_gold(int Ind) { ! player_type *p_ptr = Players[Ind]; ! Send_gold(Ind, p_ptr->au); } *************** *** 1447,1463 **** /* * Displays store (after clearing screen) -RAK- */ ! static void display_store(void) { ! char buf[80]; - /* Clear screen */ ! Term_clear(); /* The "Home" is special */ ! if (store_num == 7) { /* Put the owner name */ put_str("Your Home", 3, 30); --- 1441,1461 ---- /* * Displays store (after clearing screen) -RAK- */ ! static void display_store(int Ind) { ! player_type *p_ptr = Players[Ind]; ! store_type *st_ptr = &store[p_ptr->store_num]; /* Clear screen */ ! /*Term_clear();*/ /* The "Home" is special */ ! if (p_ptr->store_num == 7) { + /* Send the store info */ + Send_store_info(Ind, p_ptr->store_num, 0, st_ptr->stock_num); + + #if 0 /* Put the owner name */ put_str("Your Home", 3, 30); *************** *** 1469,1483 **** { put_str("Weight", 5, 70); } } /* Normal stores */ else { ! cptr store_name = (f_name + f_info[FEAT_SHOP_HEAD + store_num].name); ! cptr owner_name = (ot_ptr->owner_name); ! cptr race_name = race_info[ot_ptr->owner_race].title; /* Put the owner name and race */ sprintf(buf, "%s (%s)", owner_name, race_name); put_str(buf, 3, 10); --- 1467,1482 ---- { put_str("Weight", 5, 70); } + #endif } /* Normal stores */ else { ! /* Send the store info */ ! Send_store_info(Ind, p_ptr->store_num, st_ptr->owner, st_ptr->stock_num); + #if 0 /* Put the owner name and race */ sprintf(buf, "%s (%s)", owner_name, race_name); put_str(buf, 3, 10); *************** *** 1497,1509 **** /* Label the asking price (in stores) */ put_str("Price", 5, 72); } /* Display the current gold */ ! store_prt_gold(); /* Draw in the inventory */ ! display_inventory(); } --- 1496,1509 ---- /* Label the asking price (in stores) */ put_str("Price", 5, 72); + #endif } /* Display the current gold */ ! store_prt_gold(Ind); /* Draw in the inventory */ ! display_inventory(Ind); } *************** *** 1511,1516 **** --- 1511,1517 ---- /* * Get the ID of a store item and return its value -RAK- */ + #if 0 static int get_stock(int *com_val, cptr pmt, int i, int j) { char command; *************** *** 1560,1570 **** --- 1561,1575 ---- /* Success */ return (TRUE); } + #endif /* * Increase the insult counter and get angry if too many -RAK- + * + * Insults! I need no stinking insults! --KLJ-- */ + #if 0 static int increase_insults(void) { /* Increase insults */ *************** *** 1617,1625 **** --- 1622,1637 ---- /* Still okay */ return (FALSE); } + #endif /* + * No haggling. Not now. Not in the near future. --KLJ-- + */ + + #if 0 + + /* * Mega-Hack -- Enable "increments" */ static bool allow_inc = FALSE; *************** *** 1763,1796 **** return (FALSE); } /* * Haggling routine -RAK- * * Return TRUE if purchase is NOT successful */ ! static bool purchase_haggle(object_type *o_ptr, s32b *price) { s32b cur_ask, final_ask; ! s32b last_offer, offer; ! s32b x1, x2, x3; ! s32b min_per, max_per; ! int flag, loop_flag, noneed; ! int annoyed = 0, final = FALSE; - bool cancel = FALSE; - cptr pmt = "Asking"; - char out_val[160]; - *price = 0; /* Extract the starting offer and the final offer */ ! cur_ask = price_item(o_ptr, ot_ptr->max_inflate, FALSE); ! final_ask = price_item(o_ptr, ot_ptr->min_inflate, FALSE); /* Determine if haggling is necessary */ noneed = noneedtobargain(final_ask); --- 1775,1804 ---- return (FALSE); } + #endif + /* * Haggling routine -RAK- * * Return TRUE if purchase is NOT successful */ ! #if 0 ! static bool purchase_haggle(int Ind, object_type *o_ptr, s32b *price) { s32b cur_ask, final_ask; ! int noneed; ! int final = FALSE; cptr pmt = "Asking"; *price = 0; /* Extract the starting offer and the final offer */ ! cur_ask = price_item(Ind, o_ptr, ot_ptr->max_inflate, FALSE); ! final_ask = price_item(Ind, o_ptr, ot_ptr->min_inflate, FALSE); /* Determine if haggling is necessary */ noneed = noneedtobargain(final_ask); *************** *** 1802,1811 **** if (noneed) { /* Message summary */ ! msg_print("You eventually agree upon the price."); ! msg_print(NULL); } /* No haggle option */ else { --- 1810,1820 ---- if (noneed) { /* Message summary */ ! msg_print(Ind, "You eventually agree upon the price."); ! /*msg_print(NULL);*/ } + #if 0 /* No haggle option */ else { *************** *** 1816,1821 **** --- 1825,1831 ---- /* Apply Sales Tax */ final_ask += final_ask / 10; } + #endif /* Final price */ cur_ask = final_ask; *************** *** 1830,1836 **** --- 1840,1849 ---- cur_ask *= o_ptr->number; final_ask *= o_ptr->number; + *price = final_ask; + return (FALSE); + #if 0 /* XXX XXX XXX Display commands */ /* Haggle parameters */ *************** *** 1943,1949 **** --- 1956,1964 ---- /* Do not cancel */ return (FALSE); + #endif } + #endif /* *************** *** 1951,1979 **** * * Return TRUE if purchase is NOT successful */ ! static bool sell_haggle(object_type *o_ptr, s32b *price) { ! s32b purse, cur_ask, final_ask; ! s32b last_offer = 0, offer = 0; ! s32b x1, x2, x3; ! s32b min_per, max_per; ! int flag, loop_flag, noneed; ! int annoyed = 0, final = FALSE; ! bool cancel = FALSE; cptr pmt = "Offer"; - char out_val[160]; - *price = 0; /* Obtain the starting offer and the final offer */ ! cur_ask = price_item(o_ptr, ot_ptr->max_inflate, TRUE); ! final_ask = price_item(o_ptr, ot_ptr->min_inflate, TRUE); /* Determine if haggling is necessary */ noneed = noneedtobargain(final_ask); --- 1966,1992 ---- * * Return TRUE if purchase is NOT successful */ ! static bool sell_haggle(int Ind, object_type *o_ptr, s32b *price) { ! player_type *p_ptr = Players[Ind]; ! store_type *st_ptr = &store[p_ptr->store_num]; ! owner_type *ot_ptr = &owners[p_ptr->store_num][st_ptr->owner]; ! s32b purse, cur_ask, final_ask; + int noneed; + int final = FALSE; + cptr pmt = "Offer"; *price = 0; /* Obtain the starting offer and the final offer */ ! cur_ask = price_item(Ind, o_ptr, ot_ptr->max_inflate, TRUE); ! final_ask = price_item(Ind, o_ptr, ot_ptr->min_inflate, TRUE); /* Determine if haggling is necessary */ noneed = noneedtobargain(final_ask); *************** *** 1988,1995 **** if (final_ask >= purse) { /* Message */ ! msg_print("You instantly agree upon the price."); ! msg_print(NULL); /* Offer full purse */ final_ask = purse; --- 2001,2008 ---- if (final_ask >= purse) { /* Message */ ! msg_print(Ind, "You instantly agree upon the price."); ! /*msg_print(NULL);*/ /* Offer full purse */ final_ask = purse; *************** *** 1999,2008 **** else if (noneed) { /* Message */ ! msg_print("You eventually agree upon the price."); ! msg_print(NULL); } /* No haggle option */ else { --- 2012,2022 ---- else if (noneed) { /* Message */ ! msg_print(Ind, "You eventually agree upon the price."); ! /*msg_print(NULL);*/ } + #if 0 /* No haggle option */ else { *************** *** 2013,2018 **** --- 2027,2033 ---- /* Apply Sales Tax */ final_ask -= final_ask / 10; } + #endif /* Final price */ cur_ask = final_ask; *************** *** 2022,2027 **** --- 2037,2047 ---- pmt = "Final Offer"; } + /* Hack -- Return immediately */ + *price = final_ask; + return (FALSE); + + #if 0 /* Haggle for the whole pile */ cur_ask *= o_ptr->number; final_ask *= o_ptr->number; *************** *** 2140,2145 **** --- 2160,2166 ---- /* Do not cancel */ return (FALSE); + #endif } *************** *** 2149,2159 **** /* * Buy an item from a store -RAK- */ ! static void store_purchase(void) { ! int i, amt, choice; ! int item, item_new; s32b price, best; object_type sell_obj; --- 2170,2187 ---- /* * Buy an item from a store -RAK- */ ! void store_purchase(int Ind, int item, int amt) { ! player_type *p_ptr = Players[Ind]; + int st = p_ptr->store_num; + + store_type *st_ptr = &store[st]; + owner_type *ot_ptr = &owners[st][st_ptr->owner]; + + int i, choice; + int item_new; + s32b price, best; object_type sell_obj; *************** *** 2161,2178 **** char o_name[80]; - char out_val[160]; - /* Empty? */ if (st_ptr->stock_num <= 0) { ! if (store_num == 7) msg_print("Your home is empty."); ! else msg_print("I am currently out of stock."); return; } /* Find the number of objects on this and following pages */ i = (st_ptr->stock_num - store_top); --- 2189,2205 ---- char o_name[80]; /* Empty? */ if (st_ptr->stock_num <= 0) { ! if (p_ptr->store_num == 7) msg_print(Ind, "Your home is empty."); ! else msg_print(Ind, "I am currently out of stock."); return; } + #if 0 /* Find the number of objects on this and following pages */ i = (st_ptr->stock_num - store_top); *************** *** 2180,2186 **** if (i > 12) i = 12; /* Prompt */ ! if (store_num == 7) { sprintf(out_val, "Which item do you want to take? "); } --- 2207,2213 ---- if (i > 12) i = 12; /* Prompt */ ! if (p_ptr->store_num == 7) { sprintf(out_val, "Which item do you want to take? "); } *************** *** 2191,2205 **** /* Get the item number to be bought */ if (!get_stock(&item, out_val, 0, i-1)) return; - /* Get the actual index */ - item = item + store_top; - /* Get the actual item */ o_ptr = &st_ptr->stock[item]; /* Assume the player wants just one of them */ ! amt = 1; /* Hack -- get a "sample" object */ sell_obj = *o_ptr; --- 2218,2230 ---- /* Get the item number to be bought */ if (!get_stock(&item, out_val, 0, i-1)) return; + #endif /* Get the actual item */ o_ptr = &st_ptr->stock[item]; /* Assume the player wants just one of them */ ! /*amt = 1;*/ /* Hack -- get a "sample" object */ sell_obj = *o_ptr; *************** *** 2206,2225 **** sell_obj.number = amt; /* Hack -- require room in pack */ ! if (!inven_carry_okay(&sell_obj)) { ! msg_print("You cannot carry that many different items."); return; } /* Determine the "best" price (per item) */ ! best = price_item(&sell_obj, ot_ptr->min_inflate, FALSE); /* Find out how many the player wants */ if (o_ptr->number > 1) { /* Hack -- note cost of "fixed" items */ ! if ((store_num != 7) && (o_ptr->ident & ID_FIXED)) { msg_format("That costs %ld gold per item.", (long)(best)); } --- 2231,2251 ---- sell_obj.number = amt; /* Hack -- require room in pack */ ! if (!inven_carry_okay(Ind, &sell_obj)) { ! msg_print(Ind, "You cannot carry that many different items."); return; } /* Determine the "best" price (per item) */ ! best = price_item(Ind, &sell_obj, ot_ptr->min_inflate, FALSE); + #if 0 /* Find out how many the player wants */ if (o_ptr->number > 1) { /* Hack -- note cost of "fixed" items */ ! if ((p_ptr->store_num != 7) && (o_ptr->ident & ID_FIXED)) { msg_format("That costs %ld gold per item.", (long)(best)); } *************** *** 2230,2235 **** --- 2256,2262 ---- /* Allow user abort */ if (amt <= 0) return; } + #endif /* Create the object to be sold (structure copy) */ sell_obj = *o_ptr; *************** *** 2236,2258 **** sell_obj.number = amt; /* Hack -- require room in pack */ ! if (!inven_carry_okay(&sell_obj)) { ! msg_print("You cannot carry that many items."); return; } /* Attempt to buy it */ ! if (store_num != 7) { /* Fixed price, quick buy */ if (o_ptr->ident & ID_FIXED) { /* Assume accept */ choice = 0; /* Go directly to the "best" deal */ price = (best * sell_obj.number); } /* Haggle for it */ --- 2263,2289 ---- sell_obj.number = amt; /* Hack -- require room in pack */ ! if (!inven_carry_okay(Ind, &sell_obj)) { ! msg_print(Ind, "You cannot carry that many items."); return; } /* Attempt to buy it */ ! if (p_ptr->store_num != 7) { + /* For now, I'm assuming everything's price is "fixed" */ /* Fixed price, quick buy */ + #if 0 if (o_ptr->ident & ID_FIXED) { + #endif /* Assume accept */ choice = 0; /* Go directly to the "best" deal */ price = (best * sell_obj.number); + #if 0 } /* Haggle for it */ *************** *** 2271,2276 **** --- 2302,2308 ---- /* Hack -- Got kicked out */ if (st_ptr->store_open >= turn) return; } + #endif /* Player wants it */ *************** *** 2283,2331 **** if (p_ptr->au >= price) { /* Say "okay" */ ! say_comment_1(); /* Be happy */ ! decrease_insults(); /* Spend the money */ p_ptr->au -= price; /* Update the display */ ! store_prt_gold(); /* Hack -- buying an item makes you aware of it */ ! object_aware(&sell_obj); /* Hack -- clear the "fixed" flag from the item */ sell_obj.ident &= ~ID_FIXED; /* Describe the transaction */ ! object_desc(o_name, &sell_obj, TRUE, 3); /* Message */ ! msg_format("You bought %s for %ld gold.", o_name, (long)price); /* Let the player carry it (as if he picked it up) */ ! item_new = inven_carry(&sell_obj); /* Describe the final result */ ! object_desc(o_name, &inventory[item_new], TRUE, 3); /* Message */ ! msg_format("You have %s (%c).", o_name, index_to_label(item_new)); /* Handle stuff */ ! handle_stuff(); /* Note how many slots the store used to have */ i = st_ptr->stock_num; /* Remove the bought items from the store */ ! store_item_increase(item, -amt); ! store_item_optimize(item); /* Store is empty */ if (st_ptr->stock_num == 0) { --- 2315,2366 ---- if (p_ptr->au >= price) { /* Say "okay" */ ! say_comment_1(Ind); /* Be happy */ ! /*decrease_insults();*/ /* Spend the money */ p_ptr->au -= price; /* Update the display */ ! store_prt_gold(Ind); /* Hack -- buying an item makes you aware of it */ ! object_aware(Ind, &sell_obj); /* Hack -- clear the "fixed" flag from the item */ sell_obj.ident &= ~ID_FIXED; /* Describe the transaction */ ! object_desc(Ind, o_name, &sell_obj, TRUE, 3); /* Message */ ! msg_format(Ind, "You bought %s for %ld gold.", o_name, (long)price); /* Let the player carry it (as if he picked it up) */ ! item_new = inven_carry(Ind, &sell_obj); /* Describe the final result */ ! object_desc(Ind, o_name, &p_ptr->inventory[item_new], TRUE, 3); /* Message */ ! msg_format(Ind, "You have %s (%c).", o_name, index_to_label(item_new)); /* Handle stuff */ ! handle_stuff(Ind); /* Note how many slots the store used to have */ i = st_ptr->stock_num; /* Remove the bought items from the store */ ! store_item_increase(st, item, -amt); ! store_item_optimize(st, item); + /* Resend the basic store info */ + display_store(Ind); + /* Store is empty */ if (st_ptr->stock_num == 0) { *************** *** 2333,2342 **** if (rand_int(STORE_SHUFFLE) == 0) { /* Message */ ! msg_print("The shopkeeper retires."); /* Shuffle the store */ ! store_shuffle(store_num); } /* Maintain */ --- 2368,2377 ---- if (rand_int(STORE_SHUFFLE) == 0) { /* Message */ ! msg_print(Ind, "The shopkeeper retires."); /* Shuffle the store */ ! store_shuffle(p_ptr->store_num); } /* Maintain */ *************** *** 2343,2349 **** else { /* Message */ ! msg_print("The shopkeeper brings out some new stock."); } /* New inventory */ --- 2378,2384 ---- else { /* Message */ ! msg_print(Ind, "The shopkeeper brings out some new stock."); } /* New inventory */ *************** *** 2350,2373 **** for (i = 0; i < 10; i++) { /* Maintain the store */ ! store_maint(store_num); } - /* Start over */ - store_top = 0; - /* Redraw everything */ ! display_inventory(); } /* The item is gone */ else if (st_ptr->stock_num != i) { - /* Pick the correct screen */ - if (store_top >= st_ptr->stock_num) store_top -= 12; - /* Redraw everything */ ! display_inventory(); } /* Item is still here */ --- 2385,2402 ---- for (i = 0; i < 10; i++) { /* Maintain the store */ ! store_maint(p_ptr->store_num); } /* Redraw everything */ ! display_inventory(Ind); } /* The item is gone */ else if (st_ptr->stock_num != i) { /* Redraw everything */ ! display_inventory(Ind); } /* Item is still here */ *************** *** 2374,2380 **** else { /* Redraw the item */ ! display_entry(item); } } --- 2403,2409 ---- else { /* Redraw the item */ ! display_entry(Ind, item); } } *************** *** 2382,2388 **** else { /* Simple message (no insult) */ ! msg_print("You do not have enough gold."); } } } --- 2411,2417 ---- else { /* Simple message (no insult) */ ! msg_print(Ind, "You do not have enough gold."); } } } *************** *** 2391,2432 **** else { /* Carry the item */ ! item_new = inven_carry(&sell_obj); /* Describe just the result */ ! object_desc(o_name, &inventory[item_new], TRUE, 3); /* Message */ ! msg_format("You have %s (%c).", o_name, index_to_label(item_new)); /* Handle stuff */ ! handle_stuff(); /* Take note if we take the last one */ i = st_ptr->stock_num; /* Remove the items from the home */ ! store_item_increase(item, -amt); ! store_item_optimize(item); /* Hack -- Item is still here */ if (i == st_ptr->stock_num) { /* Redraw the item */ ! display_entry(item); } /* The item is gone */ else { - /* Nothing left */ - if (st_ptr->stock_num == 0) store_top = 0; - - /* Nothing left on that screen */ - else if (store_top >= st_ptr->stock_num) store_top -= 12; - /* Redraw everything */ ! display_inventory(); } } --- 2420,2458 ---- else { /* Carry the item */ ! item_new = inven_carry(Ind, &sell_obj); /* Describe just the result */ ! object_desc(Ind, o_name, &p_ptr->inventory[item_new], TRUE, 3); /* Message */ ! msg_format(Ind, "You have %s (%c).", o_name, index_to_label(item_new)); /* Handle stuff */ ! handle_stuff(Ind); /* Take note if we take the last one */ i = st_ptr->stock_num; /* Remove the items from the home */ ! store_item_increase(st, item, -amt); ! store_item_optimize(st, item); + /* Resend the basic store info */ + display_store(Ind); + /* Hack -- Item is still here */ if (i == st_ptr->stock_num) { /* Redraw the item */ ! display_entry(Ind, item); } /* The item is gone */ else { /* Redraw everything */ ! display_inventory(Ind); } } *************** *** 2438,2450 **** /* * Sell an item to the store (or home) */ ! static void store_sell(void) { int choice; - int item, item_pos; - int amt; ! s32b price, value, dummy; object_type sold_obj; object_type *o_ptr; --- 2464,2476 ---- /* * Sell an item to the store (or home) */ ! void store_sell(int Ind, int item, int amt) { + player_type *p_ptr = Players[Ind]; + int choice; ! s32b price; object_type sold_obj; object_type *o_ptr; *************** *** 2455,2476 **** /* Prepare a prompt */ ! if (store_num == 7) pmt = "Drop which item? "; - /* Only allow items the store will buy */ - item_tester_hook = store_will_buy; - - /* Get an item (from equip or inven) */ - if (!get_item(&item, pmt, TRUE, TRUE, FALSE)) - { - if (item == -2) msg_print("You have nothing that I want."); - return; - } - /* Get the item (in the pack) */ if (item >= 0) { ! o_ptr = &inventory[item]; } /* Get the item (on the floor) */ --- 2481,2492 ---- /* Prepare a prompt */ ! if (p_ptr->store_num == 7) pmt = "Drop which item? "; /* Get the item (in the pack) */ if (item >= 0) { ! o_ptr = &p_ptr->inventory[item]; } /* Get the item (on the floor) */ *************** *** 2480,2496 **** } ! /* Assume one item */ ! amt = 1; ! ! /* Find out how many the player wants (letter means "all") */ ! if (o_ptr->number > 1) { ! /* Get a quantity */ ! amt = get_quantity(NULL, o_ptr->number); ! ! /* Allow user abort */ ! if (amt <= 0) return; } #if 0 --- 2496,2506 ---- } ! /* Check for validity of sale */ ! if (!store_will_buy(Ind, o_ptr)) { ! msg_print(Ind, "I don't want that!"); ! return; } #if 0 *************** *** 2512,2567 **** sold_obj.number = amt; /* Get a full description */ ! object_desc(o_name, &sold_obj, TRUE, 3); /* Remove any inscription for stores */ ! if (store_num != 7) sold_obj.note = 0; /* Is there room in the store (or the home?) */ ! if (!store_check_num(&sold_obj)) { ! if (store_num == 7) msg_print("Your home is full."); ! else msg_print("I have not the room in my store to keep it."); return; } /* Real store */ ! if (store_num != 7) { /* Describe the transaction */ ! msg_format("Selling %s (%c).", o_name, index_to_label(item)); ! msg_print(NULL); /* Haggle for it */ ! choice = sell_haggle(&sold_obj, &price); ! /* Kicked out */ ! if (st_ptr->store_open >= turn) return; ! /* Sold... */ ! if (choice == 0) { /* Say "okay" */ ! say_comment_1(); /* Be happy */ ! decrease_insults(); /* Get some money */ p_ptr->au += price; /* Update the display */ ! store_prt_gold(); /* Get the inventory item */ ! o_ptr = &inventory[item]; - /* Get the "apparent" value */ - dummy = object_value(&sold_obj) * sold_obj.number; - /* Become "aware" of the item */ ! object_aware(o_ptr); /* Know the item fully */ object_known(o_ptr); --- 2522,2635 ---- sold_obj.number = amt; /* Get a full description */ ! object_desc(Ind, o_name, &sold_obj, TRUE, 3); /* Remove any inscription for stores */ ! if (p_ptr->store_num != 7) sold_obj.note = 0; /* Is there room in the store (or the home?) */ ! if (!store_check_num(p_ptr->store_num, &sold_obj)) { ! if (p_ptr->store_num == 7) msg_print(Ind, "Your home is full."); ! else msg_print(Ind, "I have not the room in my store to keep it."); return; } /* Real store */ ! if (p_ptr->store_num != 7) { /* Describe the transaction */ ! msg_format(Ind, "Selling %s (%c).", o_name, index_to_label(item)); ! /*msg_print(NULL);*/ /* Haggle for it */ ! choice = sell_haggle(Ind, &sold_obj, &price); ! /* Tell the client about the price */ ! Send_store_sell(Ind, price); ! /* Save the info for the confirmation */ ! p_ptr->current_selling = item; ! p_ptr->current_sell_amt = amt; ! p_ptr->current_sell_price = price; ! ! /* Wait for confirmation before actually selling */ ! return; ! } ! ! ! #if 0 ! /* Player is at home */ ! else { + /* Describe */ + msg_format(Ind, "You drop %s.", o_name); + + /* Take it from the players inventory */ + inven_item_increase(Ind, item, -amt); + inven_item_describe(Ind, item); + inven_item_optimize(Ind, item); + + /* Handle stuff */ + handle_stuff(Ind); + + /* Let the store (home) carry it */ + item_pos = home_carry(&sold_obj); + + /* Update store display */ + if (item_pos >= 0) + { + store_top = (item_pos / 12) * 12; + display_inventory(Ind); + } + } + #endif + } + + + void store_confirm(int Ind) + { + player_type *p_ptr = Players[Ind]; + int item, amt, price, value; + + object_type *o_ptr, sold_obj; + char o_name[80]; + int item_pos; + + /* Abort if we shouldn't be getting called */ + if (p_ptr->current_selling == -1) + return; + + /* Restore the variables */ + item = p_ptr->current_selling; + amt = p_ptr->current_sell_amt; + price = p_ptr->current_sell_price; + + /* Trash the saved variables */ + p_ptr->current_selling = -1; + p_ptr->current_sell_amt = -1; + p_ptr->current_sell_price = -1; + + /* Sold... */ + /* Say "okay" */ ! say_comment_1(Ind); /* Be happy */ ! /*decrease_insults();*/ /* Get some money */ p_ptr->au += price; /* Update the display */ ! store_prt_gold(Ind); /* Get the inventory item */ ! o_ptr = &p_ptr->inventory[item]; /* Become "aware" of the item */ ! object_aware(Ind, o_ptr); /* Know the item fully */ object_known(o_ptr); *************** *** 2577,2641 **** sold_obj.number = amt; /* Get the "actual" value */ ! value = object_value(&sold_obj) * sold_obj.number; /* Get the description all over again */ ! object_desc(o_name, &sold_obj, TRUE, 3); /* Describe the result (in message buffer) */ ! msg_format("You sold %s for %ld gold.", o_name, (long)price); /* Analyze the prices (and comment verbally) */ ! purchase_analyze(price, value, dummy); /* Take the item from the player, describe the result */ ! inven_item_increase(item, -amt); ! inven_item_describe(item); ! inven_item_optimize(item); /* Handle stuff */ ! handle_stuff(); /* The store gets that (known) item */ ! item_pos = store_carry(&sold_obj); /* Re-display if item is now in store */ if (item_pos >= 0) { ! store_top = (item_pos / 12) * 12; ! display_inventory(); } } - } - /* Player is at home */ - else - { - /* Describe */ - msg_format("You drop %s.", o_name); - /* Take it from the players inventory */ - inven_item_increase(item, -amt); - inven_item_describe(item); - inven_item_optimize(item); - /* Handle stuff */ - handle_stuff(); - - /* Let the store (home) carry it */ - item_pos = home_carry(&sold_obj); - - /* Update store display */ - if (item_pos >= 0) - { - store_top = (item_pos / 12) * 12; - display_inventory(); - } - } - } - - - /* * Hack -- set this to leave the store */ --- 2645,2684 ---- sold_obj.number = amt; /* Get the "actual" value */ ! value = object_value(Ind, &sold_obj) * sold_obj.number; /* Get the description all over again */ ! object_desc(Ind, o_name, &sold_obj, TRUE, 3); /* Describe the result (in message buffer) */ ! msg_format(Ind, "You sold %s for %ld gold.", o_name, (long)price); /* Analyze the prices (and comment verbally) */ ! /*purchase_analyze(price, value, dummy);*/ /* Take the item from the player, describe the result */ ! inven_item_increase(Ind, item, -amt); ! inven_item_describe(Ind, item); ! inven_item_optimize(Ind, item); /* Handle stuff */ ! handle_stuff(Ind); /* The store gets that (known) item */ ! item_pos = store_carry(p_ptr->store_num, &sold_obj); + /* Resend the basic store info */ + display_store(Ind); + /* Re-display if item is now in store */ if (item_pos >= 0) { ! display_inventory(Ind); } } /* * Hack -- set this to leave the store */ *************** *** 2650,2655 **** --- 2693,2699 ---- * must disable some commands which are allowed in the dungeon * but not in the stores, to prevent chaos. */ + #if 0 static void store_process_command(void) { /* Parse the command */ *************** *** 2958,2981 **** */ void do_cmd_store(int Ind) { ! msg_print(Ind, "The doors are locked."); ! ! #if 0 int which; - int tmp_chr; - cave_type *c_ptr; /* Access the player grid */ ! c_ptr = &cave[py][px]; /* Verify a store */ if (!((c_ptr->feat >= FEAT_SHOP_HEAD) && (c_ptr->feat <= FEAT_SHOP_TAIL))) { ! msg_print("You see no store here."); return; } --- 3002,3021 ---- */ void do_cmd_store(int Ind) { ! player_type *p_ptr = Players[Ind]; int which; cave_type *c_ptr; /* Access the player grid */ ! c_ptr = &cave[p_ptr->dun_depth][p_ptr->py][p_ptr->px]; /* Verify a store */ if (!((c_ptr->feat >= FEAT_SHOP_HEAD) && (c_ptr->feat <= FEAT_SHOP_TAIL))) { ! msg_print(Ind, "You see no store here."); return; } *************** *** 2985,3026 **** /* Hack -- Check the "locked doors" */ if (store[which].store_open >= turn) { ! msg_print("The doors are locked."); return; } /* Hack -- Character is in "icky" mode */ ! character_icky = TRUE; /* No command argument */ ! command_arg = 0; /* No repeated command */ ! command_rep = 0; /* No automatic command */ ! command_new = 0; /* Save the store number */ ! store_num = which; /* Save the store and owner pointers */ ! st_ptr = &store[store_num]; ! ot_ptr = &owners[store_num][st_ptr->owner]; - /* Start at the beginning */ - store_top = 0; - /* Display the store */ ! display_store(); /* Do not leave */ leave_store = FALSE; /* Interact with player */ while (!leave_store) { --- 3025,3070 ---- /* Hack -- Check the "locked doors" */ if (store[which].store_open >= turn) { ! msg_print(Ind, "The doors are locked."); return; } + /* Hack -- Ignore the home */ + if (which == 7) + { + msg_print(Ind, "The doors are locked."); + return; + } /* Hack -- Character is in "icky" mode */ ! /*character_icky = TRUE;*/ /* No command argument */ ! /*command_arg = 0;*/ /* No repeated command */ ! /*command_rep = 0;*/ /* No automatic command */ ! /*command_new = 0;*/ /* Save the store number */ ! p_ptr->store_num = which; /* Save the store and owner pointers */ ! /*st_ptr = &store[p_ptr->store_num]; ! ot_ptr = &owners[p_ptr->store_num][st_ptr->owner];*/ /* Display the store */ ! display_store(Ind); /* Do not leave */ leave_store = FALSE; + #if 0 /* Interact with player */ while (!leave_store) { *************** *** 3043,3049 **** } /* Home commands */ ! if (store_num == 7) { prt(" g) Get an item.", 22, 40); prt(" d) Drop an item.", 23, 40); --- 3087,3093 ---- } /* Home commands */ ! if (p_ptr->store_num == 7) { prt(" g) Get an item.", 22, 40); prt(" d) Drop an item.", 23, 40); *************** *** 3078,3084 **** if (inventory[INVEN_PACK].k_idx) { /* Hack -- Flee from the store */ ! if (store_num != 7) { /* Message */ msg_print("Your pack is so full that you flee the store..."); --- 3122,3128 ---- if (inventory[INVEN_PACK].k_idx) { /* Hack -- Flee from the store */ ! if (p_ptr->store_num != 7) { /* Message */ msg_print("Your pack is so full that you flee the store..."); *************** *** 3187,3192 **** --- 3231,3238 ---- void store_shuffle(int which) { int i, j; + store_type *st_ptr; + owner_type *ot_ptr; /* Ignore home */ *************** *** 3244,3249 **** --- 3290,3297 ---- int j; int old_rating = rating; + store_type *st_ptr; + owner_type *ot_ptr; /* Ignore home */ *************** *** 3276,3283 **** if (black_market_crap(o_ptr)) { /* Destroy the item */ ! store_item_increase(j, 0 - o_ptr->number); ! store_item_optimize(j); } } } --- 3324,3331 ---- if (black_market_crap(o_ptr)) { /* Destroy the item */ ! store_item_increase(store_num, j, 0 - o_ptr->number); ! store_item_optimize(store_num, j); } } } *************** *** 3299,3305 **** if (j < 0) j = 0; /* Destroy objects until only "j" slots are left */ ! while (st_ptr->stock_num > j) store_delete(); /* Choose the number of slots to fill */ --- 3347,3353 ---- if (j < 0) j = 0; /* Destroy objects until only "j" slots are left */ ! while (st_ptr->stock_num > j) store_delete(store_num); /* Choose the number of slots to fill */ *************** *** 3318,3324 **** if (j >= st_ptr->stock_size) j = st_ptr->stock_size - 1; /* Acquire some new items */ ! while (st_ptr->stock_num < j) store_create(); /* Hack -- Restore the rating */ --- 3366,3372 ---- if (j >= st_ptr->stock_size) j = st_ptr->stock_size - 1; /* Acquire some new items */ ! while (st_ptr->stock_num < j) store_create(store_num); /* Hack -- Restore the rating */ *************** *** 3332,3337 **** --- 3380,3387 ---- void store_init(int which) { int k; + store_type *st_ptr; + owner_type *ot_ptr; /* Save the store index */ Only in mangband-015/src/server: store.o Only in mangband-015/src/server: tables.o Only in mangband-015/src/server: util.o Only in mangband-015/src/server: variable.o diff -c -r -w mangband-015/src/server/xtra1.c mangband-021/src/server/xtra1.c *** mangband-015/src/server/xtra1.c Fri Mar 28 10:03:52 1997 --- mangband-021/src/server/xtra1.c Wed Apr 30 23:02:20 1997 *************** *** 582,592 **** */ static void prt_frame_basic(int Ind) { int i; /* Race and Class */ ! /*prt_field(rp_ptr->title, ROW_RACE, COL_RACE); ! prt_field(cp_ptr->title, ROW_CLASS, COL_CLASS);*/ /* Title */ prt_title(Ind); --- 582,592 ---- */ static void prt_frame_basic(int Ind) { + player_type *p_ptr = Players[Ind]; int i; /* Race and Class */ ! Send_char_info(Ind, p_ptr->prace, p_ptr->pclass, p_ptr->male); /* Title */ prt_title(Ind); *************** *** 2461,2468 **** if (p_ptr->redraw & PR_MISC) { p_ptr->redraw &= ~(PR_MISC); ! /*prt_field(rp_ptr->title, ROW_RACE, COL_RACE); ! prt_field(cp_ptr->title, ROW_CLASS, COL_CLASS);*/ } if (p_ptr->redraw & PR_TITLE) --- 2461,2467 ---- if (p_ptr->redraw & PR_MISC) { p_ptr->redraw &= ~(PR_MISC); ! Send_char_info(Ind, p_ptr->prace, p_ptr->pclass, p_ptr->male); } if (p_ptr->redraw & PR_TITLE) Only in mangband-015/src/server: xtra1.o Only in mangband-015/src/server: xtra2.o