summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoralberth <alberth@openttd.org>2009-07-25 07:49:49 +0000
committeralberth <alberth@openttd.org>2009-07-25 07:49:49 +0000
commit59c48fee8bda56a788310f6d83b99087d518fb0f (patch)
tree361d0852066b29d2a96ca1cd2a2466931b037014
parent63f2da749283621907039d551aaeb1294539fc92 (diff)
downloadopenttd-59c48fee8bda56a788310f6d83b99087d518fb0f.tar.xz
(svn r16946) -Doc: Adding docs for some string parameter manipulation functions.
-rw-r--r--src/strings.cpp8
-rw-r--r--src/strings_func.h35
2 files changed, 41 insertions, 2 deletions
diff --git a/src/strings.cpp b/src/strings.cpp
index 25699ad07..4cbe06df3 100644
--- a/src/strings.cpp
+++ b/src/strings.cpp
@@ -35,8 +35,8 @@
#include "table/strings.h"
#include "table/control_codes.h"
-DynamicLanguages _dynlang;
-uint64 _decode_parameters[20];
+DynamicLanguages _dynlang; ///< Language information of the program.
+uint64 _decode_parameters[20]; ///< Global array of string parameters. To access, use #SetDParam.
static char *StationGetSpecialString(char *buff, int x, const char *last);
static char *GetSpecialTownNameString(char *buff, int ind, uint32 seed, const char *last);
@@ -171,6 +171,10 @@ void SetDParamStr(uint n, const char *str)
SetDParam(n, (uint64)(size_t)str);
}
+/**
+ * Shift the string parameters in the global string parameter array by \a amount positions, making room at the beginning.
+ * @param amount Number of positions to shift.
+ */
void InjectDParam(uint amount)
{
assert((uint)amount < lengthof(_decode_parameters));
diff --git a/src/strings_func.h b/src/strings_func.h
index a1b090195..674d0ae3a 100644
--- a/src/strings_func.h
+++ b/src/strings_func.h
@@ -13,11 +13,22 @@ const char *GetStringPtr(StringID string);
void InjectDParam(uint amount);
+/**
+ * Set a string parameter \a v at index \a n in a given array \a s.
+ * @param s Array of string parameters.
+ * @param n Index of the string parameter.
+ * @param v Value of the string parameter.
+ */
static inline void SetDParamX(uint64 *s, uint n, uint64 v)
{
s[n] = v;
}
+/**
+ * Set a string parameter \a v at index \a n in the global string parameter array.
+ * @param n Index of the string parameter.
+ * @param v Value of the string parameter.
+ */
static inline void SetDParam(uint n, uint64 v)
{
extern uint64 _decode_parameters[20];
@@ -28,11 +39,23 @@ static inline void SetDParam(uint n, uint64 v)
void SetDParamStr(uint n, const char *str);
+/**
+ * Get the current string parameter at index \a n from parameter array \a s.
+ * @param s Array of string parameters.
+ * @param n Index of the string parameter.
+ * @return Value of the requested string parameter.
+ */
static inline uint64 GetDParamX(const uint64 *s, uint n)
{
return s[n];
}
+/**
+ * Get the current string parameter at index \a n from the global string parameter array.
+ * @param s Array of string parameters.
+ * @param n Index of the string parameter.
+ * @return Value of the requested string parameter.
+ */
static inline uint64 GetDParam(uint n)
{
extern uint64 _decode_parameters[20];
@@ -41,12 +64,24 @@ static inline uint64 GetDParam(uint n)
return _decode_parameters[n];
}
+/**
+ * Copy \a num string parameters from array \a src into the global string parameter array.
+ * @param offs Index in the global array to copy the first string parameter to.
+ * @param src Source array of string parameters.
+ * @param num Number of string parameters to copy.
+ */
static inline void CopyInDParam(int offs, const uint64 *src, int num)
{
extern uint64 _decode_parameters[20];
memcpy(_decode_parameters + offs, src, sizeof(uint64) * (num));
}
+/**
+ * Copy \a num string parameters from the global string parameter array to the \a dst array.
+ * @param dst Destination array of string parameters.
+ * @param offs Index in the global array to copy the first string parameter from.
+ * @param num Number of string parameters to copy.
+ */
static inline void CopyOutDParam(uint64 *dst, int offs, int num)
{
extern uint64 _decode_parameters[20];