summaryrefslogtreecommitdiff
path: root/src/saveload
diff options
context:
space:
mode:
authortruebrain <truebrain@openttd.org>2011-12-19 20:50:44 +0000
committertruebrain <truebrain@openttd.org>2011-12-19 20:50:44 +0000
commit5cda1d7c90f7ac2a1d8a851edbe426f07a032946 (patch)
tree49cf84b2640c39bca5b7dad70f3e19c481f7025f /src/saveload
parent577fe0238e7f4681fdf96b8aed241908a9f72de9 (diff)
downloadopenttd-5cda1d7c90f7ac2a1d8a851edbe426f07a032946.tar.xz
(svn r23603) -Add: support for control commands in strings, in both network and safe/load (Rubidium)
Diffstat (limited to 'src/saveload')
-rw-r--r--src/saveload/saveload.cpp11
-rw-r--r--src/saveload/saveload.h4
2 files changed, 12 insertions, 3 deletions
diff --git a/src/saveload/saveload.cpp b/src/saveload/saveload.cpp
index 55fabe77b..b1655512b 100644
--- a/src/saveload/saveload.cpp
+++ b/src/saveload/saveload.cpp
@@ -1089,7 +1089,14 @@ static void SlString(void *ptr, size_t length, VarType conv)
}
((char *)ptr)[len] = '\0'; // properly terminate the string
- str_validate((char *)ptr, (char *)ptr + len);
+ StringValidationSettings settings = SVS_REPLACE_WITH_QUESTION_MARK;
+ if ((conv & SLF_ALLOW_CONTROL) != 0) {
+ settings = settings | SVS_ALLOW_CONTROL_CODE;
+ }
+ if ((conv & SLF_ALLOW_NEWLINE) != 0) {
+ settings = settings | SVS_ALLOW_NEWLINE;
+ }
+ str_validate((char *)ptr, (char *)ptr + len, settings);
break;
}
case SLA_PTRS: break;
@@ -1442,7 +1449,7 @@ bool SlObjectMember(void *ptr, const SaveLoad *sld)
}
break;
case SL_ARR: SlArray(ptr, sld->length, conv); break;
- case SL_STR: SlString(ptr, sld->length, conv); break;
+ case SL_STR: SlString(ptr, sld->length, sld->conv); break;
case SL_LST: SlList(ptr, (SLRefType)conv); break;
default: NOT_REACHED();
}
diff --git a/src/saveload/saveload.h b/src/saveload/saveload.h
index cac20ce5a..c5ffbeff8 100644
--- a/src/saveload/saveload.h
+++ b/src/saveload/saveload.h
@@ -174,7 +174,9 @@ enum VarTypes {
SLF_NOT_IN_SAVE = 1 << 8, ///< do not save with savegame, basically client-based
SLF_NOT_IN_CONFIG = 1 << 9, ///< do not save to config file
SLF_NO_NETWORK_SYNC = 1 << 10, ///< do not synchronize over network (but it is saved if SLF_NOT_IN_SAVE is not set)
- /* 5 more possible flags */
+ SLF_ALLOW_CONTROL = 1 << 11, ///< allow control codes in the strings
+ SLF_ALLOW_NEWLINE = 1 << 12, ///< allow new lines in the strings
+ /* 3 more possible flags */
};
typedef uint32 VarType;