Skip to content

Commit c28d8c0

Browse files
committed
Deprecated two-argument form of add_extra_msg_file
Edits to scripting documents.
1 parent 7b3f69f commit c28d8c0

5 files changed

Lines changed: 28 additions & 31 deletions

File tree

artifacts/scripting/functions.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@
565565
doc: |
566566
Used to play `mp3/wav/wma` files. The path given is relative to the Fallout folder. Specify mode as 1 to loop the file continuously, 2 to replace the current background game music with playing the specified file in loop mode, or 0 to play the file once. If you don't wish to loop, `play_sfall_sound` returns 0. If you do loop, it returns an ID which can be passed back to `stop_sfall_sound` when you want to stop the effect. All sounds effects will be stopped on game reload, looping or not. Does not require `AllowDShowSound` to be set to 1 in `ddraw.ini`.
567567
568-
Starting from sfall 4.2.8/3.8.28, you can pass a value in the `mode` argument for a reduced sound volume. To set the volume, you need to convert the number to hexadecimal and use the argument format `0xZZZZ000Y`, where `ZZZZ` is the volume reduction value in range from 0 to 32767 (the value 32767 is mute), and `Y` is the playback mode.
568+
Starting from sfall 4.2.8/3.8.28, you can pass a value in the `mode` argument for a reduced sound volume. To set the volume, you need to convert the number to hexadecimal and use the argument format `0xZZZZ000Y`, where `ZZZZ` is the volume reduction value in the range of 0 to 32767 (the value 32767 is mute), and `Y` is the playback mode.
569569
- name: stop_sfall_sound
570570
detail: void stop_sfall_sound(int soundID)
571571
opcode: 0x822c
@@ -848,7 +848,7 @@
848848
opcode: 0x824b
849849
- name: tile_light
850850
detail: int tile_light(int elevation, int tileNum)
851-
doc: Returns light intensity at the given tile in range from 0 to 65535.
851+
doc: Returns light intensity at the given tile in the range of 0 to 65536.
852852
opcode: 0x826d
853853
- name: tile_get_objs
854854
detail: array tile_get_objs(int tileNum, int elevation)
@@ -926,11 +926,11 @@
926926
- name: set_pickpocket_max
927927
detail: void set_pickpocket_max(int percentage)
928928
opcode: 0x81a0
929-
doc: Effects all critters rather than just the player and can set the maximum in range from 0 to 999.
929+
doc: Effects all critters rather than just the player and can set the maximum in the range of 0 to 999.
930930
- name: set_hit_chance_max
931931
detail: void set_hit_chance_max(int percentage)
932932
opcode: 0x81a1
933-
doc: Effects all critters rather than just the player and can set the maximum in range from 0 to 999.
933+
doc: Effects all critters rather than just the player and can set the maximum in the range of 0 to 999.
934934
- name: set_xp_mod
935935
detail: void set_xp_mod(int percentage)
936936
opcode: 0x81aa
@@ -1010,7 +1010,7 @@
10101010
- name: get_light_level
10111011
detail: int get_light_level
10121012
opcode: 0x8226
1013-
doc: Returns ambient light level in range 0..65536. The value returned by get_light_level may not exactly match that set by `set_light_level`, as `set_light_level` applies modifiers from the Night Vision perk.
1013+
doc: Returns ambient light level in the range of 0 to 65536. The value returned by get_light_level may not exactly match that set by `set_light_level`, as `set_light_level` applies modifiers from the Night Vision perk.
10141014

10151015
- name: mark_movie_played
10161016
detail: void mark_movie_played(int id)
@@ -1483,12 +1483,12 @@
14831483
- name: add_extra_msg_file
14841484
detail: int add_extra_msg_file(string fileName)
14851485
doc: |
1486-
Loads the custom message file, and returns the file ID number assigned to it in range from 0x3000 to 0x3FFF for the `message_str_game` function to get messages from the file.
1486+
Loads a custom message file and returns the file ID number assigned to it, in the range of 0x3000 to 0x3FFF, for use with the `message_str_game` function.
14871487
- `fileName`: the name of the custom message file (including the .msg extension) in `text\<language>\game\` directory.
1488+
- __NOTE:__ if the msg file does not exist in the current language directory, the function will try to load it from the `text\English\game\` directory.
14881489
1489-
Alternative form: `int add_extra_msg_file(string fileName, int fileNumber)`
1490-
- `fileNumber`: the file ID number for the `message_str_game` function. The available range is from 0x2000 to 0x2FFF (see `ExtraGameMsgFileList` setting in `ddraw.ini`)
1491-
Use `fileNumber` only if you want to add a message file without editing `ddraw.ini` or existing scripts to support the old way.
1490+
Alternative form: `int add_extra_msg_file(string fileName, int fileNumber)` **[DEPRECATED]**
1491+
- __Deprecation notice:__ Starting from sfall 4.4.10/3.8.50, the two-argument form is deprecated. The `fileNumber` argument is ignored, and the function behaves the same as the one-argument form.
14921492
macro: sfall.h
14931493

14941494
- name: void sfall_func0("remove_timer_event")

artifacts/scripting/sfall function notes.md

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ The **type** value in the weapon knockback functions can be 0 or 1. If 0, the va
4141

4242
The `get_sfall_global` and `set_sfall_global` functions require an 8 characters long case sensitive string for the variable name. The variables behave the same as normal Fallout globals, except that they don't have to be declared beforehand in **vault13.gam**. Trying to get a variable which hasn't been set will always return 0. These functions are intended for use when a patch to a mod requires the addition of a new global variable, a case which would otherwise require the player to start a new game.
4343

44-
The `set_pickpocket_max` and `set_hit_chance_max` affect all critters rather than just the player and can set the maximum in range from 0 to 999.
44+
The `set_pickpocket_max` and `set_hit_chance_max` affect all critters rather than just the player and can set the maximum in the range of 0 to 999.
4545

4646
The `set_skill_max` can't be used to increase the skill cap above 300. The `set_perk_level_mod` sets a modifier between +25 and -25 that is added/subtracted from the player's level for the purposes of deciding which perks can be chosen.
4747

@@ -66,7 +66,7 @@ The `get_proto_data` and `set_proto_data` are used to manipulate the in memory c
6666
The `list_xxx` functions can be used to loop over all items on a map. `list_begin` takes an argument telling sfall what you want to list (defined in **sfall.h**). It returns a list pointer, which you iterate through with `list_next`. Finally, when you've finished with the list use `list_end` on it. Not calling `list_end` will result in a memory leak. Alternatively, use `list_as_array` to get the whole list at once as a temp array variable, which can be looped over using `len_array` and which you don't need to remember to free afterwards.
6767

6868
The `play_sfall_sound` and `stop_sfall_sound` are used to play **mp3/wav/wma** files. The path given is relative to the Fallout folder. Specify mode as 1 to loop the file continuously, 2 to replace the current background game music with playing the specified file in loop mode, or 0 to play the file once. If you don't wish to loop, `play_sfall_sound` returns 0. If you do loop, it returns an ID which can be passed back to `stop_sfall_sound` when you want to stop the effect. All sounds effects will be stopped on game reload, looping or not. These functions do not require **AllowDShowSound** to be set to 1 in **ddraw.ini**.
69-
Starting from sfall 4.2.8/3.8.28, you can pass a value in the **mode** argument for a reduced sound volume. To set the volume, you need to convert the number to hexadecimal and use the argument format `0xZZZZ000Y`, where `ZZZZ` is the volume reduction value in range from 0 to 32767 (the value 32767 is muted), and `Y` is the playback mode.
69+
Starting from sfall 4.2.8/3.8.28, you can pass a value in the **mode** argument for a reduced sound volume. To set the volume, you need to convert the number to hexadecimal and use the argument format `0xZZZZ000Y`, where `ZZZZ` is the volume reduction value in the range of 0 to 32767 (the value 32767 is mute), and `Y` is the playback mode.
7070

7171
Arrays are created and manipulated with the `xxx_array` functions. An array must first be created with `create_array` or `temp_array`, specifying how many data elements the array can hold. You can store any of ints, floats and strings in an array, and can mix all 3 in a single array. The ID returned by `create_array` or `temp_array` can then be used with the other array functions. Arrays are shared between all scripts. (i.e. you can call `create_array` from one script, and then use the returned ID from another script.) They are also saved across savegames. Arrays created with `temp_array` will be automatically freed at the end of the frame. These functions are safe, in that supplying a bad ID or trying to access out of range elements will not crash the script. `create_array` is the only function that returns a permanent array, all other functions which return arrays (`string_split`, `list_as_array`, etc,) all return temp arrays. You can use `fix_array` to make a temp array permanent.\
7272
__NOTE:__ refer to **arrays.md** for detailed description of the array behavior and function usage.
@@ -172,7 +172,7 @@ FUNCTION REFERENCE
172172

173173
-----
174174
#### `int get_light_level`
175-
- Ambient light level in range 0..65536
175+
- Returns ambient light level in the range of 0 to 65536.
176176
- The value returned by `get_light_level` may not exactly match that set by `set_light_level`, as `set_light_level` applies modifiers from the night vision perk.
177177

178178
-----
@@ -439,7 +439,7 @@ FUNCTION REFERENCE
439439

440440
-----
441441
#### `int tile_light(int elevation, int tileNum)`
442-
- Returns light intensity at the given tile in range from 0 to 65536.
442+
- Returns light intensity at the given tile in the range of 0 to 65536.
443443

444444
-----
445445
#### `object obj_blocking_line(object objFrom, int tileTo, int blockingType)`
@@ -858,13 +858,11 @@ sfall_funcX metarule functions
858858
----
859859
#### add_extra_msg_file
860860
`int sfall_func1("add_extra_msg_file", string fileName)`\
861-
`int sfall_func2("add_extra_msg_file", string fileName, int fileNumber)`
862-
- Loads the custom message file, and returns the file ID number assigned to it in range from `0x3000` to `0x3FFF` for the `message_str_game` function to get messages from the file
861+
`int sfall_func2("add_extra_msg_file", string fileName, int fileNumber)` **[DEPRECATED]**
862+
- Loads a custom message file and returns the file ID number assigned to it, in the range of `0x3000` to `0x3FFF`, for use with the `message_str_game` function
863863
- `fileName`: the name of the custom message file (including the **.msg** extension) in the `text\<language>\game\` directory
864864
- __NOTE:__ if the msg file does not exist in the current language directory, the function will try to load it from the `text\English\game\` directory
865-
866-
**Optional argument:**
867-
- `fileNumber`: the file ID number for the `message_str_game` function. The available range is from `0x2000` to `0x2FFF` (see **ExtraGameMsgFileList** setting in **ddraw.ini**). Use **fileNumber** only if you want to add a message file without editing **ddraw.ini** or existing scripts to support the old way
865+
- __Deprecation notice:__ Starting from sfall 4.4.10/3.8.50, the two-argument form is deprecated. The `fileNumber` argument is ignored, and the function behaves the same as the one-argument form.
868866

869867
----
870868
#### unwield_slot

sfall/Modules/Message.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -254,13 +254,8 @@ static void ReadExtraGameMsgFiles() {
254254
}
255255
}
256256

257-
long Message::AddExtraMsgFile(const char* msgName, long msgNumber) {
258-
if (msgNumber) {
259-
if (msgNumber < 0x2000 || msgNumber > 0x2FFF) return -1;
260-
if (Message::gExtraGameMsgLists.find(msgNumber) != Message::gExtraGameMsgLists.cend()) {
261-
return 0; // file has already been added
262-
}
263-
} else if (msgNumCounter > 0x3FFF) return -3;
257+
long Message::AddExtraMsgFile(const char* msgName) {
258+
if (msgNumCounter > 0x3FFF) return -3;
264259

265260
std::string path("game\\");
266261
path += msgName;
@@ -278,7 +273,7 @@ long Message::AddExtraMsgFile(const char* msgName, long msgNumber) {
278273
return -2;
279274
//}
280275
}
281-
if (msgNumber == 0) msgNumber = msgNumCounter++;
276+
long msgNumber = msgNumCounter++;
282277
Message::gExtraGameMsgLists.emplace(msgNumber, list);
283278
addedExtraMsgFiles.emplace(path, msgNumber);
284279
return msgNumber;

sfall/Modules/Message.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class Message : public Module {
6363
static ExtraGameMessageListsMap gExtraGameMsgLists;
6464
static const fo::MessageList* gameMsgFiles[];
6565

66-
static long AddExtraMsgFile(const char* msgName, long msgNumber);
66+
static long AddExtraMsgFile(const char* msgName);
6767
};
6868

6969
}

sfall/Modules/Scripting/Handlers/Utils.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -332,16 +332,20 @@ void op_message_str_game(OpcodeContext& ctx) {
332332
}
333333

334334
void mf_add_extra_msg_file(OpcodeContext& ctx) {
335-
long result = Message::AddExtraMsgFile(ctx.arg(0).strValue(), (ctx.numArgs() == 2) ? ctx.arg(1).rawValue() : 0);
335+
if (ctx.numArgs() == 2) {
336+
ctx.printOpcodeError("%s() - Warning: 2-arg form is deprecated; the 2nd argument is ignored.", ctx.getMetaruleName());
337+
}
338+
long result = Message::AddExtraMsgFile(ctx.arg(0).strValue());
336339
switch (result) {
337-
case -1 :
338-
ctx.printOpcodeError("%s() - cannot add message file with the specified number.", ctx.getMetaruleName());
339-
break;
340+
//case -1 :
341+
// ctx.printOpcodeError("%s() - cannot add message file with the specified number.", ctx.getMetaruleName());
342+
// break;
340343
case -2 :
341344
ctx.printOpcodeError("%s() - error loading message file.", ctx.getMetaruleName());
342345
break;
343346
case -3 :
344347
ctx.printOpcodeError("%s() - the limit of adding message files has been exceeded.", ctx.getMetaruleName());
348+
break;
345349
}
346350
ctx.setReturn(result);
347351
}

0 commit comments

Comments
 (0)