mirror of
https://github.com/brues-code/ClassicAPI.git
synced 2026-11-15 23:50:38 +00:00
Every RegisterFrameMethods call passed its method table and doc table with a count beside each: sizeof(t) / sizeof(t[0]), std::size, or a literal. The literals had to be kept in step with the tables by hand. Game::ArrayRef<T> is a view over a file-scope array that takes the count from the array's type, the way Doc::FieldList already did for a function's arguments and returns. FieldList is now ArrayRef<Field>, Doc::MethodList is ArrayRef<Method>, and RegisterFrameMethods takes (context, methods, docs). The table and count still go to the engine's frame-method iterator (FUN_REGISTER_FRAME_METHODS) unchanged, and to the documentation recorder. All 84 call sites pass only the arrays. The 16 literal counts were checked against their tables first: each was the full length, so every registry gets the same methods as before.
58 lines
2.0 KiB
C++
58 lines
2.0 KiB
C++
// This file is part of ClassicAPI.
|
|
//
|
|
// ClassicAPI is free software: you can redistribute it and/or modify it under the terms
|
|
// of the GNU General Public License as published by the Free Software Foundation, either
|
|
// version 3 of the License, or (at your option) any later version.
|
|
//
|
|
// ClassicAPI is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
// PURPOSE. See the GNU General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU General Public License along with
|
|
// ClassicAPI. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
// `Model:SetGlow(value)` — 4.3.4's Model method (CSimpleModel_Scripts.cpp).
|
|
//
|
|
// In 4.3.4 it calls the virtual CSimpleModel::SetGlow, which does nothing on a
|
|
// Model; only the glue screen's ModelFFX overrides it, to set the strength of
|
|
// its glow effect. In the game every Model is a plain Model, so the method
|
|
// checks its arguments the way 4.3.4 does and changes nothing.
|
|
|
|
#include "Game.h"
|
|
#include "Offsets.h"
|
|
|
|
namespace Model::Glow {
|
|
namespace {
|
|
|
|
int __fastcall Script_SetGlow(void *L) {
|
|
void *model = Game::Lua::ResolveModel(L);
|
|
if (model == nullptr)
|
|
return 0;
|
|
if (!Game::Lua::IsNumber(L, 2))
|
|
Game::Lua::Error(L, "Usage: %s:SetGlow(value)", Game::Lua::ObjectDisplayName(model));
|
|
return 0;
|
|
}
|
|
|
|
const Game::Lua::FrameMethodEntry g_methods[] = {
|
|
{"SetGlow", &Script_SetGlow},
|
|
};
|
|
|
|
const Game::Doc::Field kArgs[] = {
|
|
Game::Doc::Req("value", "number", "The glow strength."),
|
|
};
|
|
const Game::Doc::Function kSetGlow{"Sets the glow strength of the model. It has no effect in the game.",
|
|
kArgs, {}};
|
|
const Game::Doc::Method g_methodDocs[] = {
|
|
{"SetGlow", &kSetGlow},
|
|
};
|
|
|
|
void RegisterLuaFunctions() {
|
|
Game::Lua::RegisterFrameMethods(
|
|
reinterpret_cast<void *>(Offsets::VAR_MODEL_METHOD_REGISTRY), g_methods, g_methodDocs);
|
|
}
|
|
|
|
const Game::ModuleAutoRegister _autoreg{&RegisterLuaFunctions};
|
|
|
|
} // namespace
|
|
} // namespace Model::Glow
|