diff -c -r -w xpilot-4.1.0_orig/src/client/client.c xpilot-4.1.0_mod_talk/src/client/client.c *** xpilot-4.1.0_orig/src/client/client.c Wed Sep 16 19:35:40 1998 --- xpilot-4.1.0_mod_talk/src/client/client.c Mon Mar 8 05:23:50 1999 *************** *** 56,61 **** --- 56,63 ---- #define MAX_CHECKPOINT 26 + char *fast_msgs[N_MSGS]; + int scoresChanged = 0; int RadarHeight = 0; diff -c -r -w xpilot-4.1.0_orig/src/client/client.h xpilot-4.1.0_mod_talk/src/client/client.h *** xpilot-4.1.0_orig/src/client/client.h Wed Sep 16 19:35:40 1998 --- xpilot-4.1.0_mod_talk/src/client/client.h Thu Mar 11 02:34:35 1999 *************** *** 252,257 **** --- 252,259 ---- extern int maxVolume; /* maximum volume (in percent) */ #endif /* SOUND */ + extern int snoopEyesId; /* client's view of game */ + int Fuel_by_pos(int x, int y); int Target_alive(int x, int y, int *damage); int Target_by_index(int ind, int *xp, int *yp, int *dead_time, int *damage); diff -c -r -w xpilot-4.1.0_orig/src/client/default.c xpilot-4.1.0_mod_talk/src/client/default.c *** xpilot-4.1.0_orig/src/client/default.c Tue Oct 6 15:52:19 1998 --- xpilot-4.1.0_mod_talk/src/client/default.c Mon Mar 8 05:23:50 1999 *************** *** 71,76 **** --- 71,80 ---- char default_version[] = VERSION; + extern char *fast_msgs[]; + char fast_temp_buf[7]; /* can handle up to 999 fast msgs */ + char *fast_temp_buf_big; + #ifndef lint static char sourceid[] = "@(#)$Id: default.c,v 4.7 1998/10/06 14:52:19 bert Exp $"; *************** *** 1658,1664 **** "Specifies the device name of the frame buffer.\n" }, #endif ! }; --- 1662,1947 ---- "Specifies the device name of the frame buffer.\n" }, #endif ! { ! "keySendMsg1", ! NULL, ! "F1", ! KEY_MSG_1, ! "Sends the talkmessage stored in msg1.\n" ! }, ! { ! "msg1", ! NULL, ! "", ! KEY_DUMMY, ! "Talkmessage 1.\n" ! }, ! { ! "keySendMsg2", ! NULL, ! "F2", ! KEY_MSG_2, ! "Sends the talkmessage stored in msg2.\n" ! }, ! { ! "msg2", ! NULL, ! "", ! KEY_DUMMY, ! "Talkmessage 2.\n" ! }, ! { ! "keySendMsg3", ! NULL, ! "F3", ! KEY_MSG_3, ! "Sends the talkmessage stored in msg3.\n" ! }, ! { ! "msg3", ! NULL, ! "", ! KEY_DUMMY, ! "Talkmessage 3.\n" ! }, ! { ! "keySendMsg4", ! NULL, ! "F4", ! KEY_MSG_4, ! "Sends the talkmessage stored in msg4.\n" ! }, ! { ! "msg4", ! NULL, ! "", ! KEY_DUMMY, ! "Talkmessage 4.\n" ! }, ! { ! "keySendMsg5", ! NULL, ! "F5", ! KEY_MSG_5, ! "Sends the talkmessage stored in msg5.\n" ! }, ! { ! "msg5", ! NULL, ! "", ! KEY_DUMMY, ! "Talkmessage 5.\n" ! }, ! { ! "keySendMsg6", ! NULL, ! "F6", ! KEY_MSG_6, ! "Sends the talkmessage stored in msg6.\n" ! }, ! { ! "msg6", ! NULL, ! "", ! KEY_DUMMY, ! "Talkmessage 6.\n" ! }, ! { ! "keySendMsg7", ! NULL, ! "F7", ! KEY_MSG_7, ! "Sends the talkmessage stored in msg7.\n" ! }, ! { ! "msg7", ! NULL, ! "", ! KEY_DUMMY, ! "Talkmessage 7.\n" ! }, ! { ! "keySendMsg8", ! NULL, ! "F8", ! KEY_MSG_8, ! "Sends the talkmessage stored in msg8.\n" ! }, ! { ! "msg8", ! NULL, ! "", ! KEY_DUMMY, ! "Talkmessage 8.\n" ! }, ! { ! "keySendMsg9", ! NULL, ! "F9", ! KEY_MSG_9, ! "Sends the talkmessage stored in msg9.\n" ! }, ! { ! "msg9", ! NULL, ! "", ! KEY_DUMMY, ! "Talkmessage 9.\n" ! }, ! { ! "keySendMsg10", ! NULL, ! "F10", ! KEY_MSG_10, ! "Sends the talkmessage stored in msg10.\n" ! }, ! { ! "msg10", ! NULL, ! "", ! KEY_DUMMY, ! "Talkmessage 10.\n" ! }, ! { ! "keySendMsg11", ! NULL, ! "F11", ! KEY_MSG_11, ! "Sends the talkmessage stored in msg11.\n" ! }, ! { ! "msg11", ! NULL, ! "", ! KEY_DUMMY, ! "Talkmessage 11.\n" ! }, ! { ! "keySendMsg12", ! NULL, ! "F12", ! KEY_MSG_12, ! "Sends the talkmessage stored in msg12.\n" ! }, ! { ! "msg12", ! NULL, ! "", ! KEY_DUMMY, ! "Talkmessage 12.\n" ! }, ! { ! "keySendMsg13", ! NULL, ! "", ! KEY_MSG_13, ! "Sends the talkmessage stored in msg13.\n" ! }, ! { ! "msg13", ! NULL, ! "", ! KEY_DUMMY, ! "Talkmessage 13.\n" ! }, ! { ! "keySendMsg14", ! NULL, ! "", ! KEY_MSG_14, ! "Sends the talkmessage stored in msg14.\n" ! }, ! { ! "msg14", ! NULL, ! "", ! KEY_DUMMY, ! "Talkmessage 14.\n" ! }, ! { ! "keySendMsg15", ! NULL, ! "", ! KEY_MSG_15, ! "Sends the talkmessage stored in msg15.\n" ! }, ! { ! "msg15", ! NULL, ! "", ! KEY_DUMMY, ! "Talkmessage 15.\n" ! }, ! { ! "keySendMsg16", ! NULL, ! "", ! KEY_MSG_16, ! "Sends the talkmessage stored in msg16.\n" ! }, ! { ! "msg16", ! NULL, ! "", ! KEY_DUMMY, ! "Talkmessage 16.\n" ! }, ! { ! "keySendMsg17", ! NULL, ! "", ! KEY_MSG_17, ! "Sends the talkmessage stored in msg17.\n" ! }, ! { ! "msg17", ! NULL, ! "", ! KEY_DUMMY, ! "Talkmessage 17.\n" ! }, ! { ! "keySendMsg18", ! NULL, ! "", ! KEY_MSG_18, ! "Sends the talkmessage stored in msg18.\n" ! }, ! { ! "msg18", ! NULL, ! "", ! KEY_DUMMY, ! "Talkmessage 18.\n" ! }, ! { ! "keySendMsg19", ! NULL, ! "", ! KEY_MSG_19, ! "Sends the talkmessage stored in msg19.\n" ! }, ! { ! "msg19", ! NULL, ! "", ! KEY_DUMMY, ! "Talkmessage 19.\n" ! }, ! { ! "keySendMsg20", ! NULL, ! "", ! KEY_MSG_20, ! "Sends the talkmessage stored in msg20.\n" ! }, ! { ! "msg20", ! NULL, ! "", ! KEY_DUMMY, ! "Talkmessage 20.\n" ! }, }; *************** *** 2270,2275 **** --- 2553,2572 ---- #endif /* _WINDOWS */ + + if ((fast_temp_buf_big = (char *)malloc(FAST_MSG_SIZE)) != NULL) + { + for (i = 0; i < N_MSGS; ++i) + { + sprintf (fast_temp_buf, "msg%d", i + 1); + Get_resource(rDB, fast_temp_buf, fast_temp_buf_big, FAST_MSG_SIZE); + fast_msgs[i] = strdup (fast_temp_buf_big); + } + free (fast_temp_buf_big); + } + else + for (i = 0; i < N_MSGS; ++i) + fast_msgs[i] = NULL; Get_bool_resource(rDB, "ignoreWindowManager", &ignoreWindowManager); diff -c -r -w xpilot-4.1.0_orig/src/client/netclient.c xpilot-4.1.0_mod_talk/src/client/netclient.c *** xpilot-4.1.0_orig/src/client/netclient.c Sun Aug 30 17:36:50 1998 --- xpilot-4.1.0_mod_talk/src/client/netclient.c Thu Mar 11 02:34:56 1999 *************** *** 2408,2413 **** --- 2408,2743 ---- return 0; } + #define TEAM_PLAY (1<<8) /* defined in rules.h */ + #define LIMITED_LIVES (1<<3) /* defined in rules.h */ + #define MSG_PARSED_FIELD_LEN 20 + + /* Returns a pointer to the first character after the fields */ + char *Fields_info (char *buf, int *n_fields) + { + int end_found = 0, level = 0; + + *n_fields = 0; + while (!end_found) + { + switch (*buf) + { + case START_DELIMITER: + if (level++ == 0) + (*n_fields)++; + break; + case MIDDLE_DELIMITER: + if (level == 1) + (*n_fields)++; + break; + case END_DELIMITER: + level--; + if (level == 0) + end_found = 1; + else if (level < 0) + return NULL; + break; + case '\0': + return NULL; + break; + default: + break; + } + buf++; + } + return buf; + } + + /* Returns a string pointer to the wanted_field + * This pointer must be freed after using it + */ + char *Field_get (char *buf, int wanted_field) + { + int finished = 0, level = 0, field = 0, len; + char *field_ptr, *start_ptr = NULL, *end_ptr = NULL; + + while (!finished) + { + switch (*buf) + { + case START_DELIMITER: + if (level == 0) + { + field++; + if (field == wanted_field) + start_ptr = buf + 1; + } + level++; + break; + case MIDDLE_DELIMITER: + if (level == 1) + { + field++; + if (field == wanted_field) + start_ptr = buf + 1; + else if (field == wanted_field + 1) + { + end_ptr = buf; + finished = 1; + } + } + break; + case END_DELIMITER: + level--; + if (level == 0) + { + if (field == wanted_field) + end_ptr = buf; + finished = 1; + } + else if (level < 0) + return NULL; + break; + case '\0': + return NULL; + break; + default: + break; + } + buf++; + + } + len = end_ptr - start_ptr; + field_ptr = (char *) malloc (len + 1); + strncpy (field_ptr, start_ptr, len); + field_ptr[len] = '\0'; + return field_ptr; + } + + int Net_talk_parsed(char *str) + { + /* Comment: sizeof talk_str === MAX_CHARS */ + if (str == NULL) + return 1; + + if (Parse (talk_str, str, 0L, MAX_CHARS) > 0) + { + talk_pending = ++talk_sequence_num; + talk_last_send = last_loops - TALK_RETRY; + } + return 0; + } + + int Parse(char *outbuf, char *inbuf, long pos, long max) + { + FILE *fp; + char c; + long fsize; + int i, n_fields; + char *tmpptr, *tmpptr1, *tmpptr2, *tmpptr3, *nextpos, *filename; + other_t *player=NULL; + + + while ((c = *inbuf++) != '\0') + { + if (pos >= max - 2) + { + if (outbuf == talk_str) /* parsing to the talk buffer */ + { + outbuf[pos] = '\0'; + talk_pending = ++talk_sequence_num; + if (Packet_printf(&wbuf, "%c%ld%s", PKT_TALK, + talk_pending, outbuf) == -1) + return -1; + pos = 0; + } + else + goto done; + } + if (player != NULL) + { + switch (c) + { + case 'l': + if (BIT(Setup->mode, LIMITED_LIVES)) + outbuf[pos++] = player->life + '0'; + break; + case 'n': + tmpptr = player->name; + for (i = 0; tmpptr[i] != '\0' && pos < max - 2; ++i) + outbuf[pos++] = tmpptr[i]; + break; + case 's': + if (pos < max - 1 - 6) /* short - "-16535" max no of chars */ + pos += sprintf (outbuf+pos, "%d", player->score); + break; + case 't': + if (BIT(Setup->mode, TEAM_PLAY)) + outbuf[pos++] = player->team + '0'; + break; + default: + break; + } + player = NULL; + } + else + { + switch (c) + { + case SPECIAL_TALK_CHAR: + if ((c = *inbuf++) == '\0') + goto done; + switch (c) { + case '=': /* String comparison */ + nextpos = Fields_info (inbuf, &n_fields); + if (n_fields < 3 || n_fields > 4 || nextpos == NULL) + break; + /* parse field 1 */ + if ((tmpptr = Field_get (inbuf, 1)) == NULL) + { + printf ("Field_get (1) error!...\n"); + break; + } + tmpptr1 = (char *)malloc (MSG_PARSED_FIELD_LEN); + Parse (tmpptr1, tmpptr, 0, MSG_PARSED_FIELD_LEN); + free (tmpptr); + /* parse field 2 */ + if ((tmpptr = Field_get (inbuf, 2)) == NULL) + { + printf ("Field_get (2) error!...\n"); + break; + } + tmpptr2 = (char *)malloc (MSG_PARSED_FIELD_LEN); + Parse (tmpptr2, tmpptr, 0, MSG_PARSED_FIELD_LEN); + free (tmpptr); + if (!strcmp(tmpptr1, tmpptr2)) + { + /* True */ + if ((tmpptr3 = Field_get (inbuf, 3)) == NULL) + { + printf ("Field_get (3) error!...\n"); + free (tmpptr1); + free (tmpptr2); + break; + } + pos = Parse (outbuf, tmpptr3, pos, max); + } + else if (n_fields == 4) + { + /* False */ + if ((tmpptr3 = Field_get (inbuf, 4)) == NULL) + { + printf ("Field_get (4) error!...\n"); + free (tmpptr1); + free (tmpptr2); + break; + } + pos = Parse (outbuf, tmpptr3, pos, max); + } + inbuf = nextpos; + free (tmpptr); + free (tmpptr1); + free (tmpptr2); + free (tmpptr3); + break; + case 'f': + nextpos = Fields_info (inbuf, &n_fields); + if (n_fields != 1 || nextpos == NULL) + break; + if ((tmpptr = Field_get (inbuf, 1)) == NULL) + { + printf ("Field_get error!...\n"); + break; + } + inbuf = nextpos; + filename = (char *)malloc (MSG_FNLEN); + Parse (filename, tmpptr, 0, MSG_FNLEN); + free (tmpptr); + if ((fp = fopen (filename, "r")) == NULL) + { + printf ("Couldn't open file %s\n", tmpptr); + free (filename); + break; + } + free (filename); + + /* Get filesize */ + fseek (fp, 0L, SEEK_END); + fsize = ftell (fp); + rewind (fp); + + if ((tmpptr = (char *)malloc(fsize+1)) == NULL) + { + fclose (fp); + break; + } + fread (tmpptr, 1, fsize, fp); + tmpptr[fsize] = '\0'; + fclose (fp); + pos = Parse (outbuf, tmpptr, pos, max); + free (tmpptr); + break; + case 'h': + tmpptr = getenv ("HOME"); + while (*tmpptr != '\0' && pos < max - 2) + outbuf[pos++] = *tmpptr++; + break; + case 'r': + nextpos = Fields_info (inbuf, &n_fields); + if (n_fields <= 0 || nextpos == NULL) + break; + if ((tmpptr = Field_get (inbuf, rand() % n_fields + 1)) + == NULL) + { + printf ("Field_get error (random) \n"); + break; + } + inbuf = nextpos; + pos = Parse (outbuf, tmpptr, pos, max); + free (tmpptr); + break; + case 'n': + outbuf[pos] = '\0'; + talk_pending = ++talk_sequence_num; + if (Packet_printf(&wbuf, "%c%ld%s", PKT_TALK, + talk_pending, outbuf) == -1) + return -1; + pos = 0; + break; + case 'l': + if ( Other_by_id(snoopEyesId) == self + || Other_by_id(snoopEyesId) == NULL ){ + if ((player = Other_by_id(lock_id)) == NULL) { + pos = 0; + goto done; + } + } else { + if ((player = Other_by_id(snoopEyesId)) == NULL) { + pos = 0; + goto done; + } + } + break; + case 's': + player = self; + break; + case 't': + if (BIT(Setup->mode, TEAM_PLAY)) + outbuf[pos++] = self->team + '0'; + break; + case SPECIAL_TALK_CHAR: + outbuf[pos++] = c; + break; + default: + break; + } + case '\n': + break; + default: + outbuf[pos++] = c; + break; + } + } + } + done: + outbuf[pos] = '\0'; + return pos; + } int Send_talk(void) { diff -c -r -w xpilot-4.1.0_orig/src/client/netclient.h xpilot-4.1.0_mod_talk/src/client/netclient.h *** xpilot-4.1.0_orig/src/client/netclient.h Thu Apr 16 18:39:29 1998 --- xpilot-4.1.0_mod_talk/src/client/netclient.h Tue Mar 9 04:13:14 1999 *************** *** 113,117 **** --- 113,119 ---- int Send_audio_request(int onoff); int Send_fps_request(int fps); int Receive_loseitem(void); + int Net_talk_parsed(char *str); + int Parse(char *outbuf, char *inbuf, long pos, long max); #endif diff -c -r -w xpilot-4.1.0_orig/src/client/paintobjects.c xpilot-4.1.0_mod_talk/src/client/paintobjects.c *** xpilot-4.1.0_orig/src/client/paintobjects.c Wed Sep 16 19:35:41 1998 --- xpilot-4.1.0_mod_talk/src/client/paintobjects.c Thu Mar 11 02:29:29 1999 *************** *** 651,656 **** --- 651,657 ---- } if (num_ship > 0) { + snoopEyesId = -1; for (i = 0; i < num_ship; i++) { x = ship_ptr[i].x; y = ship_ptr[i].y; *************** *** 665,670 **** --- 666,679 ---- points[cnt].y = WINSCALE(Y(y + ship->pts[cnt][dir].y)); } points[cnt++] = points[0]; + + /* + * ship in the center? (svenska-hack) + */ + if ( abs(X(x)-view_width/2) <=1 && abs(Y(y)-view_height/2) <=1 + && Other_by_id(ship_ptr[i].id) != NULL ){ + snoopEyesId = ship_ptr[i].id; + } /* * Determine if the name of the player should be drawn below diff -c -r -w xpilot-4.1.0_orig/src/client/xevent.c xpilot-4.1.0_mod_talk/src/client/xevent.c *** xpilot-4.1.0_orig/src/client/xevent.c Tue Oct 6 15:52:19 1998 --- xpilot-4.1.0_mod_talk/src/client/xevent.c Mon Mar 8 05:23:50 1999 *************** *** 57,62 **** --- 57,64 ---- char xevent_version[] = VERSION; + extern char *fast_msgs[]; + extern setup_t *Setup; static BITV_DECL(keyv, NUM_KEYS); *************** *** 283,288 **** --- 285,293 ---- static bool Key_press(keys_t key) { + if (key >= KEY_MSG_1 && key < KEY_MSG_1 + N_MSGS) + Net_talk_parsed (fast_msgs[key - KEY_MSG_1]); + switch (key) { case KEY_ID_MODE: showRealName = showRealName ? false : true; diff -c -r -w xpilot-4.1.0_orig/src/client/xpilot.c xpilot-4.1.0_mod_talk/src/client/xpilot.c *** xpilot-4.1.0_orig/src/client/xpilot.c Thu Apr 16 18:39:56 1998 --- xpilot-4.1.0_mod_talk/src/client/xpilot.c Thu Mar 11 02:35:08 1999 *************** *** 96,101 **** --- 96,103 ---- char **Argv; int Argc; + int snoopEyesId = -1; + static void Check_client_versions(void); diff -c -r -w xpilot-4.1.0_orig/src/common/const.h xpilot-4.1.0_mod_talk/src/common/const.h *** xpilot-4.1.0_orig/src/common/const.h Sat Aug 29 20:49:53 1998 --- xpilot-4.1.0_mod_talk/src/common/const.h Mon Mar 8 05:23:50 1999 *************** *** 405,408 **** --- 405,416 ---- extern char* strdup(const char*); #endif + #define N_MSGS 20 + #define FAST_MSG_SIZE 400 + #define MSG_FNLEN 100 + #define START_DELIMITER '[' + #define END_DELIMITER ']' + #define MIDDLE_DELIMITER '|' + #define SPECIAL_TALK_CHAR '#' + #endif diff -c -r -w xpilot-4.1.0_orig/src/common/keys.h xpilot-4.1.0_mod_talk/src/common/keys.h *** xpilot-4.1.0_orig/src/common/keys.h Thu Apr 16 18:40:42 1998 --- xpilot-4.1.0_mod_talk/src/common/keys.h Mon Mar 8 05:23:50 1999 *************** *** 116,121 **** --- 116,142 ---- * retaining compatibility. Change this at the next major cleanup. */ , + KEY_MSG_1, + KEY_MSG_2, + KEY_MSG_3, + KEY_MSG_4, + KEY_MSG_5, + KEY_MSG_6, + KEY_MSG_7, + KEY_MSG_8, + KEY_MSG_9, + KEY_MSG_10, + KEY_MSG_11, + KEY_MSG_12, + KEY_MSG_13, + KEY_MSG_14, + KEY_MSG_15, + KEY_MSG_16, + KEY_MSG_17, + KEY_MSG_18, + KEY_MSG_19, + KEY_MSG_20, + KEY_ID_MODE, KEY_TOGGLE_OWNED_ITEMS, KEY_TOGGLE_MESSAGES,