瀏覽代碼

* Updated showmsg with Shinomori's improvements

git-svn-id: https://svn.code.sf.net/p/rathena/svn/branches/stable@1404 54d463be-8e91-2dee-dedb-b68131a5f0ec
celest 20 年之前
父節點
當前提交
d9881083d4
共有 2 個文件被更改,包括 16 次插入13 次删除
  1. 1 0
      Changelog-SVN.txt
  2. 15 13
      src/common/showmsg.c

+ 1 - 0
Changelog-SVN.txt

@@ -2,6 +2,7 @@
 Date	Added
 
 04/04
+	* Updated showmsg with Shinomori's improvements [celest]
         * Fix showmsg for Visual Studio [MouseJstr]
 	* Update base code for the UPNP plugin loading [celest]
 	* Removed anti-freeze system for login and char -- Shinomori's update would

+ 15 - 13
src/common/showmsg.c

@@ -1,25 +1,22 @@
 #include <stdio.h>
-#include <stdlib.h>
 #include <string.h>
 #include <stdarg.h>
 #include "showmsg.h"
-#include "malloc.h"
 
 char tmp_output[1024] = {"\0"};
 
 #undef ShowMessage
 
+// by MC Cameri
 int _vShowMessage(enum msg_type flag, const char *string, va_list ap)
-{ // by MC Cameri
-	/* 
-		_ShowMessage MUST be used instead of printf as of 10/24/2004.
-		Return: 0 = Successful, 1 = Failed.
-	*/
+{
+	// _ShowMessage MUST be used instead of printf as of 10/24/2004.
+	// Return: 0 = Successful, 1 = Failed.
 //	int ret = 0;
+//	char *output;
 	char prefix[40];
-	char *output;
 	
-	if (strlen(string) <= 0) {
+	if (!string || strlen(string) <= 0) {
 		printf("Empty string passed to _ShowMessage().\n");
 		return 1;
 	}
@@ -49,11 +46,12 @@ int _vShowMessage(enum msg_type flag, const char *string, va_list ap)
 			strcpy(prefix,CL_RED"[Fatal Error]"CL_RESET":");
 			break;
 		default:
-                        printf("In function _ShowMessage() -> Invalid flag passed.\n");
+			printf("In function _ShowMessage() -> Invalid flag passed.\n");
 			return 1;
 	}
 	if (!(flag == MSG_DEBUG && !SHOW_DEBUG_MSG)) {
-		output = (char*)aMalloc(sizeof(char)*(strlen(prefix)+strlen(string)+2)); // prefix+string+two chars(space and \0)
+
+/*		output = (char*)aMalloc(sizeof(char)*(strlen(prefix)+strlen(string)+2)); // prefix+string+two chars(space and \0)
 		if (output == NULL) {
 			return 1;
 //			exit(1); // Kill server? Deadly
@@ -64,7 +62,11 @@ int _vShowMessage(enum msg_type flag, const char *string, va_list ap)
 		strcat(output,string);
 		vprintf(output, ap);
 		fflush(stdout);
-		aFree(output);
+		aFree(output);*/
+
+		printf ("%s ", prefix);
+		vprintf (string, ap);
+		fflush (stdout);
 	}
 
 	va_end(ap);
@@ -86,7 +88,7 @@ int _vShowMessage(enum msg_type flag, const char *string, va_list ap)
 	return 0;
 }
 
-int _ShowMessage(enum msg_type flag, const char *string, ...) 
+int _ShowMessage(enum msg_type flag, const char *string, ...)
 {
   	va_list ap;