mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-23 04:33:09 +00:00
MOHAWK: Implement stringLen and substring LBCode functions.
This commit is contained in:
parent
33a85af915
commit
e4fc8e85ed
@ -686,8 +686,8 @@ struct CodeCommandInfo {
|
||||
CodeCommandInfo generalCommandInfo[NUM_GENERAL_COMMANDS] = {
|
||||
{ "eval", &LBCode::cmdEval },
|
||||
{ "random", &LBCode::cmdRandom },
|
||||
{ "stringLen", 0 },
|
||||
{ "substring", 0 },
|
||||
{ "stringLen", &LBCode::cmdStringLen },
|
||||
{ "substring", &LBCode::cmdSubstring },
|
||||
{ "max", 0 },
|
||||
{ "min", 0 },
|
||||
{ "abs", 0 },
|
||||
@ -861,6 +861,31 @@ void LBCode::cmdRandom(const Common::Array<LBValue> ¶ms) {
|
||||
_stack.push(_vm->_rnd->getRandomNumberRng(min, max));
|
||||
}
|
||||
|
||||
void LBCode::cmdStringLen(const Common::Array<LBValue> ¶ms) {
|
||||
if (params.size() != 1)
|
||||
error("incorrect number of parameters (%d) to stringLen", params.size());
|
||||
|
||||
const Common::String &string = params[0].toString();
|
||||
_stack.push(string.size());
|
||||
}
|
||||
|
||||
void LBCode::cmdSubstring(const Common::Array<LBValue> ¶ms) {
|
||||
if (params.size() != 3)
|
||||
error("incorrect number of parameters (%d) to substring", params.size());
|
||||
|
||||
const Common::String &string = params[0].toString();
|
||||
uint begin = params[1].toInt();
|
||||
uint end = params[2].toInt();
|
||||
if (begin == 0)
|
||||
error("invalid substring call (%d to %d)", begin, end);
|
||||
if (begin > end || end > string.size()) {
|
||||
_stack.push(Common::String());
|
||||
return;
|
||||
}
|
||||
Common::String substring(string.c_str() + (begin - 1), end - begin + 1);
|
||||
_stack.push(substring);
|
||||
}
|
||||
|
||||
void LBCode::cmdGetRect(const Common::Array<LBValue> ¶ms) {
|
||||
if (params.size() < 2) {
|
||||
_stack.push(getRectFromParams(params));
|
||||
|
@ -222,6 +222,8 @@ public:
|
||||
void cmdUnimplemented(const Common::Array<LBValue> ¶ms);
|
||||
void cmdEval(const Common::Array<LBValue> ¶ms);
|
||||
void cmdRandom(const Common::Array<LBValue> ¶ms);
|
||||
void cmdStringLen(const Common::Array<LBValue> ¶ms);
|
||||
void cmdSubstring(const Common::Array<LBValue> ¶ms);
|
||||
void cmdGetRect(const Common::Array<LBValue> ¶ms);
|
||||
void cmdTopLeft(const Common::Array<LBValue> ¶ms);
|
||||
void cmdBottomRight(const Common::Array<LBValue> ¶ms);
|
||||
|
Loading…
x
Reference in New Issue
Block a user