Merge branch 'master' into jgrpp
# Conflicts: # src/error.h # src/error_gui.cpp # src/linkgraph/linkgraph_gui.cpp # src/misc_gui.cpp # src/newgrf_gui.cpp # src/news_gui.cpp # src/rail_cmd.cpp # src/saveload/gamelog_sl.cpp # src/script/api/script_text.cpp # src/script/script_instance.cpp # src/statusbar_gui.cpp # src/strings.cpp # src/strings_func.h # src/strings_internal.h # src/table/settings/gui_settings.ini # src/table/settings/linkgraph_settings.ini # src/textbuf_gui.h
This commit is contained in:
@@ -905,12 +905,11 @@ void RewindTextRefStack()
|
||||
* @param scc the string control code that has been read
|
||||
* @param buff the buffer we're writing to
|
||||
* @param str the string that we need to write
|
||||
* @param argv the OpenTTD stack of values
|
||||
* @param argv_size space on the stack \a argv
|
||||
* @param modify_argv When true, modify the OpenTTD stack.
|
||||
* @param parameters the OpenTTD string formatting parameters
|
||||
* @param modify_parameters When true, modify the OpenTTD string formatting parameters.
|
||||
* @return the string control code to "execute" now
|
||||
*/
|
||||
uint RemapNewGRFStringControlCode(uint scc, char *buf_start, char **buff, const char **str, int64 *argv, uint argv_size, bool modify_argv)
|
||||
uint RemapNewGRFStringControlCode(uint scc, char *buf_start, char **buff, const char **str, StringParameters ¶meters, bool modify_parameters)
|
||||
{
|
||||
auto too_many_newgrf_params = [&]() {
|
||||
const char *buffer = *str;
|
||||
@@ -963,7 +962,7 @@ uint RemapNewGRFStringControlCode(uint scc, char *buf_start, char **buff, const
|
||||
case SCC_NEWGRF_PRINT_DWORD_FORCE:
|
||||
case SCC_NEWGRF_PRINT_WORD_STATION_NAME:
|
||||
case SCC_NEWGRF_PRINT_WORD_CARGO_NAME:
|
||||
if (argv_size < 1) {
|
||||
if (parameters.GetDataLeft() < 1) {
|
||||
too_many_newgrf_params();
|
||||
return 0;
|
||||
}
|
||||
@@ -973,47 +972,47 @@ uint RemapNewGRFStringControlCode(uint scc, char *buf_start, char **buff, const
|
||||
case SCC_NEWGRF_PRINT_WORD_CARGO_LONG:
|
||||
case SCC_NEWGRF_PRINT_WORD_CARGO_SHORT:
|
||||
case SCC_NEWGRF_PRINT_WORD_CARGO_TINY:
|
||||
if (argv_size < 2) {
|
||||
if (parameters.GetDataLeft() < 2) {
|
||||
too_many_newgrf_params();
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (_newgrf_textrefstack.used && modify_argv) {
|
||||
if (_newgrf_textrefstack.used && modify_parameters) {
|
||||
/* There is data on the NewGRF text stack, and we want to move them to OpenTTD's string stack.
|
||||
* After this call, a new call is made with `modify_argv` set to false when the string is finally formatted. */
|
||||
* After this call, a new call is made with `modify_parameters` set to false when the string is finally formatted. */
|
||||
switch (scc) {
|
||||
default: NOT_REACHED();
|
||||
case SCC_NEWGRF_PRINT_BYTE_SIGNED: *argv = _newgrf_textrefstack.PopSignedByte(); break;
|
||||
case SCC_NEWGRF_PRINT_QWORD_CURRENCY: *argv = _newgrf_textrefstack.PopSignedQWord(); break;
|
||||
case SCC_NEWGRF_PRINT_BYTE_SIGNED: parameters.SetParam(0, _newgrf_textrefstack.PopSignedByte()); break;
|
||||
case SCC_NEWGRF_PRINT_QWORD_CURRENCY: parameters.SetParam(0, _newgrf_textrefstack.PopSignedQWord()); break;
|
||||
|
||||
case SCC_NEWGRF_PRINT_DWORD_CURRENCY:
|
||||
case SCC_NEWGRF_PRINT_DWORD_SIGNED: *argv = _newgrf_textrefstack.PopSignedDWord(); break;
|
||||
case SCC_NEWGRF_PRINT_DWORD_SIGNED: parameters.SetParam(0, _newgrf_textrefstack.PopSignedDWord()); break;
|
||||
|
||||
case SCC_NEWGRF_PRINT_BYTE_HEX: *argv = _newgrf_textrefstack.PopUnsignedByte(); break;
|
||||
case SCC_NEWGRF_PRINT_QWORD_HEX: *argv = _newgrf_textrefstack.PopUnsignedQWord(); break;
|
||||
case SCC_NEWGRF_PRINT_BYTE_HEX: parameters.SetParam(0, _newgrf_textrefstack.PopUnsignedByte()); break;
|
||||
case SCC_NEWGRF_PRINT_QWORD_HEX: parameters.SetParam(0, _newgrf_textrefstack.PopUnsignedQWord()); break;
|
||||
|
||||
case SCC_NEWGRF_PRINT_WORD_SPEED:
|
||||
case SCC_NEWGRF_PRINT_WORD_VOLUME_LONG:
|
||||
case SCC_NEWGRF_PRINT_WORD_VOLUME_SHORT:
|
||||
case SCC_NEWGRF_PRINT_WORD_SIGNED: *argv = _newgrf_textrefstack.PopSignedWord(); break;
|
||||
case SCC_NEWGRF_PRINT_WORD_SIGNED: parameters.SetParam(0, _newgrf_textrefstack.PopSignedWord()); break;
|
||||
|
||||
case SCC_NEWGRF_PRINT_WORD_HEX:
|
||||
case SCC_NEWGRF_PRINT_WORD_WEIGHT_LONG:
|
||||
case SCC_NEWGRF_PRINT_WORD_WEIGHT_SHORT:
|
||||
case SCC_NEWGRF_PRINT_WORD_POWER:
|
||||
case SCC_NEWGRF_PRINT_WORD_STATION_NAME:
|
||||
case SCC_NEWGRF_PRINT_WORD_UNSIGNED: *argv = _newgrf_textrefstack.PopUnsignedWord(); break;
|
||||
case SCC_NEWGRF_PRINT_WORD_UNSIGNED: parameters.SetParam(0, _newgrf_textrefstack.PopUnsignedWord()); break;
|
||||
|
||||
case SCC_NEWGRF_PRINT_DWORD_FORCE:
|
||||
case SCC_NEWGRF_PRINT_DWORD_DATE_LONG:
|
||||
case SCC_NEWGRF_PRINT_DWORD_DATE_SHORT:
|
||||
case SCC_NEWGRF_PRINT_DWORD_HEX: *argv = _newgrf_textrefstack.PopUnsignedDWord(); break;
|
||||
case SCC_NEWGRF_PRINT_DWORD_HEX: parameters.SetParam(0, _newgrf_textrefstack.PopUnsignedDWord()); break;
|
||||
|
||||
/* Dates from NewGRFs have 1920-01-01 as their zero point, convert it to OpenTTD's epoch. */
|
||||
case SCC_NEWGRF_PRINT_WORD_DATE_LONG:
|
||||
case SCC_NEWGRF_PRINT_WORD_DATE_SHORT: *argv = _newgrf_textrefstack.PopUnsignedWord() + DAYS_TILL_ORIGINAL_BASE_YEAR; break;
|
||||
case SCC_NEWGRF_PRINT_WORD_DATE_SHORT: parameters.SetParam(0, _newgrf_textrefstack.PopUnsignedWord() + DAYS_TILL_ORIGINAL_BASE_YEAR); break;
|
||||
|
||||
case SCC_NEWGRF_DISCARD_WORD: _newgrf_textrefstack.PopUnsignedWord(); break;
|
||||
|
||||
@@ -1024,17 +1023,17 @@ uint RemapNewGRFStringControlCode(uint scc, char *buf_start, char **buff, const
|
||||
case SCC_NEWGRF_PRINT_WORD_CARGO_LONG:
|
||||
case SCC_NEWGRF_PRINT_WORD_CARGO_SHORT:
|
||||
case SCC_NEWGRF_PRINT_WORD_CARGO_TINY:
|
||||
argv[0] = GetCargoTranslation(_newgrf_textrefstack.PopUnsignedWord(), _newgrf_textrefstack.grffile);
|
||||
argv[1] = _newgrf_textrefstack.PopUnsignedWord();
|
||||
parameters.SetParam(0, GetCargoTranslation(_newgrf_textrefstack.PopUnsignedWord(), _newgrf_textrefstack.grffile));
|
||||
parameters.SetParam(1, _newgrf_textrefstack.PopUnsignedWord());
|
||||
break;
|
||||
|
||||
case SCC_NEWGRF_PRINT_WORD_STRING_ID:
|
||||
*argv = MapGRFStringID(_newgrf_textrefstack.grffile->grfid, _newgrf_textrefstack.PopUnsignedWord());
|
||||
parameters.SetParam(0, MapGRFStringID(_newgrf_textrefstack.grffile->grfid, _newgrf_textrefstack.PopUnsignedWord()));
|
||||
break;
|
||||
|
||||
case SCC_NEWGRF_PRINT_WORD_CARGO_NAME: {
|
||||
CargoID cargo = GetCargoTranslation(_newgrf_textrefstack.PopUnsignedWord(), _newgrf_textrefstack.grffile);
|
||||
*argv = cargo < NUM_CARGO ? 1ULL << cargo : 0;
|
||||
parameters.SetParam(0, cargo < NUM_CARGO ? 1ULL << cargo : 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user