(svn r2950) -Fix: [ 1259327 ] Server crash with "say" -command
This commit is contained in:
		
							
								
								
									
										16
									
								
								texteff.c
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								texteff.c
									
									
									
									
									
								
							@@ -55,25 +55,21 @@ extern void memcpy_pitch(void *d, void *s, int w, int h, int spitch, int dpitch)
 | 
				
			|||||||
// Duration is in game-days
 | 
					// Duration is in game-days
 | 
				
			||||||
void CDECL AddTextMessage(uint16 color, uint8 duration, const char *message, ...)
 | 
					void CDECL AddTextMessage(uint16 color, uint8 duration, const char *message, ...)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int i;
 | 
						char buf[MAX_TEXTMESSAGE_LENGTH], buf2[MAX_TEXTMESSAGE_LENGTH];
 | 
				
			||||||
	char buf[1024];
 | 
					 | 
				
			||||||
	char buf2[MAX_TEXTMESSAGE_LENGTH];
 | 
					 | 
				
			||||||
	va_list va;
 | 
						va_list va;
 | 
				
			||||||
	int length;
 | 
						int i, length;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	va_start(va, message);
 | 
						va_start(va, message);
 | 
				
			||||||
	vsnprintf(buf, lengthof(buf), message, va);
 | 
						vsnprintf(buf, lengthof(buf), message, va);
 | 
				
			||||||
	va_end(va);
 | 
						va_end(va);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* Special color magic */
 | 
						/* Special color magic */
 | 
				
			||||||
	if ((color & 0xFF) == 0xC9)
 | 
						if ((color & 0xFF) == 0xC9) color = 0x1CA;
 | 
				
			||||||
		color = 0x1CA;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* Cut the message till it fits inside the chatbox */
 | 
						/* Cut the message till it fits inside the chatbox */
 | 
				
			||||||
	length = strlen(buf) + 1;
 | 
						snprintf(buf2, lengthof(buf2), "%s", buf); // remove any formatting
 | 
				
			||||||
	snprintf(buf2, length, "%s", buf);
 | 
						length = strlen(buf2);
 | 
				
			||||||
	while (GetStringWidth(buf2) > _textmessage_width - 9)
 | 
						while (GetStringWidth(buf2) > _textmessage_width - 9) buf2[--length] = '\0';
 | 
				
			||||||
		snprintf(buf2, --length, "%s", buf);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* Find an empty spot and put the message there */
 | 
						/* Find an empty spot and put the message there */
 | 
				
			||||||
	for (i = 0; i < MAX_CHAT_MESSAGES; i++) {
 | 
						for (i = 0; i < MAX_CHAT_MESSAGES; i++) {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user