X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=pr_edict.c;h=23a05d1f95b6864c63d289f4733a753b2788d903;hb=bbddca18cb97718e921ada3a4c2dbd36828a6e50;hp=78fd1176347a3bae46999121973ba48ee566896b;hpb=c4ee1bbcc6b2f917465f07269ad09942bbf40849;p=xonotic%2Fdarkplaces.git diff --git a/pr_edict.c b/pr_edict.c index 78fd1176..23a05d1f 100644 --- a/pr_edict.c +++ b/pr_edict.c @@ -452,10 +452,12 @@ Easier to parse than PR_ValueString */ char *PR_UglyValueString (etype_t type, eval_t *val) { - static char line[256]; - ddef_t *def; - dfunction_t *f; - + static char line[4096]; + int i; + char *s; + ddef_t *def; + dfunction_t *f; + type &= ~DEF_SAVEGLOBAL; switch (type) @@ -472,7 +474,28 @@ char *PR_UglyValueString (etype_t type, eval_t *val) break; case ev_field: def = ED_FieldAtOfs ( val->_int ); - sprintf (line, "%s", pr_strings + def->s_name); + // LordHavoc: parse the string a bit to turn special characters + // (like newline, specifically) into escape codes, + // this fixes saving games from various mods + //sprintf (line, "%s", pr_strings + def->s_name); + s = pr_strings + def->s_name; + for (i = 0;i < 4095 && *s;) + { + if (*s == '\n') + { + line[i++] = '\\'; + line[i++] = 'n'; + } + else if (*s == '\r') + { + line[i++] = '\\'; + line[i++] = 'r'; + } + else + line[i] = *s; + s++; + } + line[i++] = 0; break; case ev_void: sprintf (line, "void"); @@ -487,7 +510,7 @@ char *PR_UglyValueString (etype_t type, eval_t *val) sprintf (line, "bad type %i", type); break; } - + return line; } @@ -645,7 +668,7 @@ void ED_Write (QFile *f, edict_t *ed) Qprintf (f, "}\n"); return; } - + for (i=1 ; inumfielddefs ; i++) { d = &pr_fielddefs[i];