Parcourir la source

Feat: cumulative update

chat.c          Increased to timeout for the handshake from 5 to 30 seconds.
dzp il y a 1 an
Parent
commit
898dc01cde
5 fichiers modifiés avec 58 ajouts et 11 suppressions
  1. 8 0
      TODO
  2. 2 0
      mods/igr.mods
  3. 43 8
      src/chat.c
  4. 4 2
      src/help.c
  5. 1 1
      src/update.c

+ 8 - 0
TODO

@@ -1,9 +1,13 @@
 - #draw tile 1 1 1 1 {\x7B}
 
+- With internet down, #session reconnect events might fail
+
 - Add an example script to display time left on tickers using #info tickers save
 
 - comprehensive memory breakdown for variables/triggers/mapper/etc
 
+- a better trigger stack debug buffer
+
 - Problem with restoring true color subs.
 #sub bla {<F00AA00>bla}
 #high blo <118>
@@ -20,6 +24,8 @@
 - https://github.com/mintty/mintty/wiki/CtrlSeqs#audio-support
 - mintty --configdir DIRNAME
 
+- Fix: #ERROR: UNKNOWN TOKEN TYPE: 14 (#info tokenizer)
+
 - split screen scrollback setting in #screen
 
 - terrain based weight modifier
@@ -219,6 +225,8 @@
 
 * LOW PRIORITY
 
+  - #if {1 || bla} errors out
+
   - ./configure might error on /dev/ptmx
 
   - Add a file handler.

+ 2 - 0
mods/igr.mods

@@ -1,5 +1,7 @@
 Jan 2024        2.02.42
 ------------------------------------------------------------------------------
+chat.c          Increased to timeout for the handshake from 5 to 30 seconds.
+
 substitute.c    %%%s would get escaped to %%s in aliases and actions. This was
                 changed so only %%%1 gets escaped to %%1, %%%s stays the same.
 

+ 43 - 8
src/chat.c

@@ -153,7 +153,7 @@ DO_CHAT(chat_initialize)
 		syserr_printf(gtd->ses, "chat_initialize: setsockopt");
 	}
 
-	ld.l_onoff  = 0; 
+	ld.l_onoff  = 0;
 	ld.l_linger = 100;
 
 	setsockopt(sock, SOL_SOCKET, SO_LINGER, (char *) &ld, sizeof(ld));
@@ -380,12 +380,32 @@ void *threaded_chat_call(void *arg)
 	new_buddy->prefix   = strdup("");
 	new_buddy->version  = strdup("");
 
+	new_buddy->timeout  = gtd->time + CALL_TIMEOUT * 6;
+
 	strip_vt102_codes(gtd->chat->name, name);
 
 	chat_socket_printf(new_buddy, "CHAT:%s\n%s%-5u", name, gtd->chat->ip, gtd->chat->port);
 
 	chat_printf("Socket connected, negotiating protocol...");
 
+#ifdef HAVE_LIBPTHREAD
+	while (gtd->chat->update)
+	{
+		chat_printf("Blocking the linking of %s.", new_buddy->name);
+
+		usleep(1000);
+
+		continue;
+	}
+#endif
+	LINK(new_buddy, gtd->chat->next, gtd->chat->prev);
+
+	freeaddrinfo(address);
+
+	return NULL;
+
+//	old code
+
 	FD_ZERO(&rds);
 	FD_SET(sock, &rds);
 
@@ -690,6 +710,8 @@ int process_chat_input(struct chat_data *buddy)
 			{
 				if (node != buddy && !strcasecmp(name, node->name))
 				{
+					// allow a relog from the same IP.
+
 					if (!strcmp(buddy->ip, node->ip))
 					{
 						close_chat(node, TRUE);
@@ -717,6 +739,15 @@ int process_chat_input(struct chat_data *buddy)
 				return -1;
 			}
 		}
+		else
+		{
+			chat_socket_printf(buddy, "%c\n%s has refused your connection due to an invalid handshake. (%s)\n%c", CHAT_MESSAGE, gtd->chat->name, buf, CHAT_END_OF_COMMAND);
+
+			chat_printf("Refusing connection from %.21s:%d, invalid handshake.", buddy->ip, buddy->port);
+
+			pop_call();
+			return -1;
+		}
 
 		strip_vt102_codes(gtd->chat->name, name);
 
@@ -740,6 +771,10 @@ int process_chat_input(struct chat_data *buddy)
 
 			RESTRING(buddy->name, name);
 
+			buddy->timeout = 0;
+
+			chat_printf("Connection made to %s.", buddy->name);
+
 			chat_socket_printf(buddy, "%c%s %s%c", CHAT_VERSION, CLIENT_NAME, CLIENT_VERSION, CHAT_END_OF_COMMAND);
 
 			get_chat_commands(buddy, sep, size - strlen(temp) - 1);
@@ -1445,7 +1480,7 @@ DO_CHAT(chat_paste)
 			if ((buddy = find_buddy(name)) != NULL)
 			{
 				chat_printf("You paste to %s:\n%s", buddy->name, gtd->chat->paste_buf);
-	
+
 				chat_socket_printf(buddy, "%c\n%s pastes to you:\n%s\n%c", CHAT_TEXT_EVERYBODY, gtd->chat->name, gtd->chat->paste_buf, CHAT_END_OF_COMMAND);
 			}
 			else if (find_group(name) != NULL)
@@ -1621,12 +1656,12 @@ DO_CHAT(chat_serve)
 	if (HAS_BIT(buddy->flags, CHAT_FLAG_SERVE))
 	{
 		chat_printf("You are now chat serving %s.", buddy->name);
-		chat_socket_printf(buddy, "%c\n%s is now chat serving you.\n%c", CHAT_MESSAGE, gtd->chat->name, CHAT_END_OF_COMMAND); 
+		chat_socket_printf(buddy, "%c\n%s is now chat serving you.\n%c", CHAT_MESSAGE, gtd->chat->name, CHAT_END_OF_COMMAND);
 	}
 	else
 	{
 		chat_printf("You are no longer chat serving %s.", buddy->name);
-		chat_socket_printf(buddy, "%c\n%s is no longer chat serving you.\n%c", CHAT_MESSAGE, gtd->chat->name, CHAT_END_OF_COMMAND); 
+		chat_socket_printf(buddy, "%c\n%s is no longer chat serving you.\n%c", CHAT_MESSAGE, gtd->chat->name, CHAT_END_OF_COMMAND);
 	}
 }
 
@@ -1885,7 +1920,7 @@ void chat_receive_file(char *arg, struct chat_data *buddy)
 		deny_file(buddy, "\nFile protocol error. (no file size was transmitted)\n");
 
 		pop_call();
-		return;	
+		return;
 	}
 	*comma = 0;
 
@@ -2079,7 +2114,7 @@ void file_cleanup(struct chat_data *buddy)
 	if (buddy->file_name)
 	{
 		free(buddy->file_name);
-		
+
 		buddy->file_name = NULL;
 	}
 }
@@ -2325,7 +2360,7 @@ DO_CHAT(chat_private)
 			{
 				chat_socket_printf(buddy, "%c\n%s marked your connection private.\n%c", CHAT_MESSAGE, gtd->chat->name, CHAT_END_OF_COMMAND);
 
-				chat_printf("Your connection with %s is now private.", buddy->name);				
+				chat_printf("Your connection with %s is now private.", buddy->name);
 
 				SET_BIT(buddy->flags, CHAT_FLAG_PRIVATE);
 			}
@@ -2363,7 +2398,7 @@ DO_CHAT(chat_public)
 			{
 				chat_socket_printf(buddy, "%c\n%s marked your connection public.\n%c", CHAT_MESSAGE, gtd->chat->name, CHAT_END_OF_COMMAND);
 
-				chat_printf("Your connection with %s is now public.", buddy->name);				
+				chat_printf("Your connection with %s is now public.", buddy->name);
 
 				DEL_BIT(buddy->flags, CHAT_FLAG_PRIVATE);
 			}

+ 4 - 2
src/help.c

@@ -3452,7 +3452,7 @@ struct help_type help_table[] =
 		"<278>         default room number (vnum) 1 is created, so you can go to it using\n"
 		"<278>         #map goto 1. Once you are inside the map new rooms are automatically\n"
 		"<278>         created as you move around. Movement commands are defined with the\n"
-		"<278>         pathdir command. By default n, ne, e, se, s, sw, w, nw, u, d are\n"
+		"<278>         #pathdir command. By default n, ne, e, se, s, sw, w, nw, u, d are\n"
 		"<278>         defined.\n"
 		"\n"
 		"<278>         <178>#map map <rows> <cols> <append|overwrite|list|variable> <name>\n"
@@ -3497,7 +3497,9 @@ struct help_type help_table[] =
 		"<278>         <178>#map write <filename>\n"
 		"\n"
 		"<278>         You can save your map using #map write, to load a map you can use\n"
-		"<278>         #map read <filename>.\n"
+		"<278>         #map read <filename>. You can return to the room you were in when\n"
+		"<278>         the map was last saved by using #map return. You can use #event to\n"
+		"<278>         automatically read and write the map on session start and end.\n"
 		"\n"
 		"<278>         <178>#map set <option> <value>\n"
 		"\n"

+ 1 - 1
src/update.c

@@ -781,7 +781,7 @@ void update_chat(void)
 
 			if (buddy->timeout && buddy->timeout < gtd->time)
 			{
-				chat_socket_printf(buddy, "<CHAT> Connection timed out.");
+				chat_socket_printf(buddy, "%c\n%s closed the connection because no handshake was completed.\n%c", CHAT_MESSAGE, gtd->chat->name, CHAT_END_OF_COMMAND);
 
 				close_chat(buddy, TRUE);
 			}