Skip to content

Commit

Permalink
Add our custom gsc funcs
Browse files Browse the repository at this point in the history
  • Loading branch information
ineed bots committed Sep 16, 2023
1 parent 2e50e32 commit 6b61239
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 6 deletions.
17 changes: 17 additions & 0 deletions src/codsrc/clientscript/cscr_compiler.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <stdinc.hpp>
#include "clientscript_public.hpp"
#include <component/gsc.hpp>

#pragma warning(push)
#pragma warning(disable: 4244)
Expand Down Expand Up @@ -2010,6 +2011,14 @@ namespace codsrc

}

// our addition
auto f = gsc::function::get(pName, type);
if (f != nullptr)
{
return f;
}
//

// pluto
if (game::plutonium::scr_get_function_hook != nullptr)
{
Expand Down Expand Up @@ -2145,6 +2154,14 @@ namespace codsrc
}
}

// our addition
auto f = gsc::method::get(pName, type);
if (f != nullptr)
{
return f;
}
//

// pluto
if (game::plutonium::scr_get_method_hook != nullptr)
{
Expand Down
24 changes: 20 additions & 4 deletions src/component/gsc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,17 @@ namespace gsc
functions.insert_or_assign(name, function);
}

const std::unordered_map<std::string, game::BuiltinFunction>& get()
game::BuiltinFunction get(const char** name, int* type)
{
return functions;
auto got = functions.find(*name);

if (got == functions.end())
{
return nullptr;
}

*type = 0;
return got->second;
}
}

Expand All @@ -122,9 +130,17 @@ namespace gsc
methods.insert_or_assign(name, method);
}

const std::unordered_map<std::string, game::BuiltinMethod>& get()
game::BuiltinMethod get(const char** name, int* type)
{
return methods;
auto got = methods.find(*name);

if (got == methods.end())
{
return nullptr;
}

*type = 0;
return got->second;
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/component/gsc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ namespace gsc
namespace function
{
void add(const std::string& name, const game::BuiltinFunction function);
const std::unordered_map<std::string, game::BuiltinFunction>& get();
game::BuiltinFunction get(const char** name, int* type);
}

namespace method
{
void add(const std::string& name, const game::BuiltinMethod method);
const std::unordered_map<std::string, game::BuiltinMethod>& get();
game::BuiltinMethod get(const char** name, int* type);
}
}

0 comments on commit 6b61239

Please sign in to comment.