mirror of
https://github.com/sfall-team/sfall.git
synced 2026-07-27 16:52:34 -07:00
Updated docs for improved string_format
Edited error messages for a few functions. ConsoleWindow: disallowed negative window position.
This commit is contained in:
@@ -1072,7 +1072,9 @@
|
|||||||
items:
|
items:
|
||||||
- name: sprintf
|
- name: sprintf
|
||||||
detail: string sprintf(string format, any value)
|
detail: string sprintf(string format, any value)
|
||||||
doc: Formats given value using standart syntax of C printf function (google "printf" for format details). However it is limited to formatting only 1 value. Can be used to get character by ASCII code ("%c").
|
doc: |
|
||||||
|
Formats given value using standart syntax of C `printf` function (google "printf" for format details). However, it is limited to formatting only 1 value.
|
||||||
|
- Can be used to get character by ASCII code ("%c").
|
||||||
opcode: 0x8250
|
opcode: 0x8250
|
||||||
- name: typeof
|
- name: typeof
|
||||||
detail: int typeof(any value)
|
detail: int typeof(any value)
|
||||||
@@ -1117,8 +1119,8 @@
|
|||||||
- name: string_format
|
- name: string_format
|
||||||
detail: string string_format(string format, any val1, any val2, ...)
|
detail: string string_format(string format, any val1, any val2, ...)
|
||||||
doc: |
|
doc: |
|
||||||
Formats given value using standard syntax of C printf function (google "printf" for format details). However it is limited to formatting up to 4 values.
|
Formats given values using standard syntax of C `printf` function (google "printf" for format details). However, it is limited to formatting up to 7 values.
|
||||||
- formatting is only supported for %s and %d, and the format string is limited to 1024 characters
|
- The format string is limited to 1024 characters
|
||||||
macro: sfall.h
|
macro: sfall.h
|
||||||
- name: string_to_case
|
- name: string_to_case
|
||||||
detail: string sfall_func2("string_to_case", string text, int toCase)
|
detail: string sfall_func2("string_to_case", string text, int toCase)
|
||||||
|
|||||||
@@ -339,7 +339,7 @@ FUNCTION REFERENCE
|
|||||||
|
|
||||||
-----
|
-----
|
||||||
##### `string sprintf(string format, any value)`
|
##### `string sprintf(string format, any value)`
|
||||||
- Formats given value using standard syntax of C `printf` function (google "printf" for format details). However it is limited to formatting only 1 value.
|
- Formats given value using standard syntax of C `printf` function (google "printf" for format details). However, it is limited to formatting only 1 value.
|
||||||
- Can be used to get character by ASCII code (`%c`).
|
- Can be used to get character by ASCII code (`%c`).
|
||||||
|
|
||||||
-----
|
-----
|
||||||
@@ -930,9 +930,10 @@ sfall_funcX metarule functions
|
|||||||
|
|
||||||
----
|
----
|
||||||
#### string_format
|
#### string_format
|
||||||
`string sfall_func3("string_format", string format, any val1, any val2, ...)`
|
`string sfall_func2("string_format", string format, any val1)`
|
||||||
- Formats given value using standard syntax of C `printf` function (google "printf" for format details). However it is limited to formatting up to 4 values
|
`string sfall_funcX("string_format", string format, any val1, any val2, ...)`
|
||||||
- Formatting is only supported for `%s` and `%d`, and the format string is limited to 1024 characters
|
- Formats given values using standard syntax of C `printf` function (google "printf" for format details). However, it is limited to formatting up to 7 values
|
||||||
|
- The format string is limited to 1024 characters
|
||||||
|
|
||||||
----
|
----
|
||||||
#### objects_in_radius
|
#### objects_in_radius
|
||||||
|
|||||||
@@ -61,10 +61,10 @@ void ConsoleWindow::loadPosition() {
|
|||||||
screenHeight = GetSystemMetrics(SM_CYSCREEN);
|
screenHeight = GetSystemMetrics(SM_CYSCREEN);
|
||||||
int w = min(max(windowData[2], 640), screenWidth),
|
int w = min(max(windowData[2], 640), screenWidth),
|
||||||
h = min(max(windowData[3], 480), screenHeight),
|
h = min(max(windowData[3], 480), screenHeight),
|
||||||
x = min(max(windowData[0], -w/2), screenWidth - w/2),
|
x = min(max(windowData[0], 0), screenWidth - w/2),
|
||||||
y = min(max(windowData[1], -h/2), screenHeight - h/2);
|
y = min(max(windowData[1], 0), screenHeight - h/2);
|
||||||
|
|
||||||
dlog_f("Settings Console Window pos: %d, %d, size: %dx%d. Screen: %dx%d.\n", DL_MAIN, x, y, w, h, screenWidth, screenHeight);
|
dlog_f("Setting console window position: (%d, %d), size: %dx%d\n", DL_MAIN, x, y, w, h);
|
||||||
if (!SetWindowPos(wnd, HWND_TOP, 0, 0, w, h, SWP_NOMOVE)) {
|
if (!SetWindowPos(wnd, HWND_TOP, 0, 0, w, h, SWP_NOMOVE)) {
|
||||||
dlog_f("Error resizing console window: 0x%x\n", DL_MAIN, GetLastError());
|
dlog_f("Error resizing console window: 0x%x\n", DL_MAIN, GetLastError());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ bool displayKarmaChanges;
|
|||||||
|
|
||||||
static DWORD __stdcall DrawCard() {
|
static DWORD __stdcall DrawCard() {
|
||||||
int reputation = fo::var::game_global_vars[fo::GVAR_PLAYER_REPUTATION];
|
int reputation = fo::var::game_global_vars[fo::GVAR_PLAYER_REPUTATION];
|
||||||
for (auto& info : karmaFrms) {
|
for (const auto& info : karmaFrms) {
|
||||||
if (reputation < info.points) {
|
if (reputation < info.points) {
|
||||||
return info.frm;
|
return info.frm;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ void op_set_script(OpcodeContext& ctx) {
|
|||||||
|
|
||||||
long scriptIndex = valArg & ~0xF0000000;
|
long scriptIndex = valArg & ~0xF0000000;
|
||||||
if (scriptIndex == 0 || valArg > 0x8FFFFFFF) { // negative values are not allowed
|
if (scriptIndex == 0 || valArg > 0x8FFFFFFF) { // negative values are not allowed
|
||||||
ctx.printOpcodeError("%s() - the script index number is incorrect.", ctx.getOpcodeName());
|
ctx.printOpcodeError("%s() - invalid script index number.", ctx.getOpcodeName());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
scriptIndex--;
|
scriptIndex--;
|
||||||
@@ -430,7 +430,7 @@ void mf_item_make_explosive(OpcodeContext& ctx) {
|
|||||||
if (pid > 0 && pidActive > 0) {
|
if (pid > 0 && pidActive > 0) {
|
||||||
Explosions::AddToExplosives(pid, pidActive, min, max);
|
Explosions::AddToExplosives(pid, pidActive, min, max);
|
||||||
} else {
|
} else {
|
||||||
ctx.printOpcodeError("%s() - invalid PID number, must be greater than 0.", ctx.getMetaruleName());
|
ctx.printOpcodeError("%s() - invalid PID number.", ctx.getMetaruleName());
|
||||||
ctx.setReturn(-1);
|
ctx.setReturn(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -232,8 +232,7 @@ static const char* sprintf_lite(OpcodeContext& ctx, const char* opcodeName) {
|
|||||||
} else {
|
} else {
|
||||||
if (c == '%') {
|
if (c == '%') {
|
||||||
conversion = false; // escaped % sign, just skip
|
conversion = false; // escaped % sign, just skip
|
||||||
}
|
} else if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) {
|
||||||
else if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) {
|
|
||||||
// ignore size prefixes
|
// ignore size prefixes
|
||||||
if (c == 'h' || c == 'l' || c == 'j' || c == 'z' || c == 't' || c == 'w' || c == 'L' || c == 'I') continue;
|
if (c == 'h' || c == 'l' || c == 'j' || c == 'z' || c == 't' || c == 'w' || c == 'L' || c == 'I') continue;
|
||||||
// Type specifier, perform conversion.
|
// Type specifier, perform conversion.
|
||||||
@@ -242,9 +241,9 @@ static const char* sprintf_lite(OpcodeContext& ctx, const char* opcodeName) {
|
|||||||
}
|
}
|
||||||
const auto& arg = ctx.arg(valIdx < numArgs ? valIdx : numArgs - 1);
|
const auto& arg = ctx.arg(valIdx < numArgs ? valIdx : numArgs - 1);
|
||||||
if (c == 'S' || c == 'Z') {
|
if (c == 'S' || c == 'Z') {
|
||||||
c = 's'; // don't allow wide-strings.
|
c = 's'; // don't allow wide strings
|
||||||
}
|
}
|
||||||
if (c == 's' && !arg.isString() || // don't allow to treat non-string values as string pointers
|
if (c == 's' && !arg.isString() || // don't allow treating non-string values as string pointers
|
||||||
c == 'n') // don't allow "n" specifier
|
c == 'n') // don't allow "n" specifier
|
||||||
{
|
{
|
||||||
c = 'd';
|
c = 'd';
|
||||||
@@ -278,7 +277,7 @@ static const char* sprintf_lite(OpcodeContext& ctx, const char* opcodeName) {
|
|||||||
|
|
||||||
void op_sprintf(OpcodeContext& ctx) {
|
void op_sprintf(OpcodeContext& ctx) {
|
||||||
ctx.setReturn(
|
ctx.setReturn(
|
||||||
sprintf_lite(ctx, "op_sprintf")
|
sprintf_lite(ctx, ctx.getOpcodeName())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,4 +32,3 @@ public:
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user