Random cleanup

This commit is contained in:
momo5502 2019-09-27 22:35:57 +02:00
parent 320d57599e
commit 9f98190944
37 changed files with 2965 additions and 3080 deletions

View File

@ -1,10 +1,8 @@
#include "std_include.hpp" #include "std_include.hpp"
#include "context_initializer.hpp" #include "context_initializer.hpp"
namespace game namespace game::scripting
{ {
namespace scripting
{
context::context() : executer_(this), scheduler_(this), parameters_(this), event_handler_(this) context::context() : executer_(this), scheduler_(this), parameters_(this), event_handler_(this)
{ {
context_initializer::initialize(this); context_initializer::initialize(this);
@ -34,5 +32,4 @@ namespace game
{ {
return &this->chai_; return &this->chai_;
} }
}
} }

View File

@ -4,10 +4,8 @@
#include "parameters.hpp" #include "parameters.hpp"
#include "event_handler.hpp" #include "event_handler.hpp"
namespace game namespace game::scripting
{ {
namespace scripting
{
class context final class context final
{ {
public: public:
@ -28,5 +26,4 @@ namespace game
parameters parameters_; parameters parameters_;
event_handler event_handler_; event_handler event_handler_;
}; };
}
} }

View File

@ -1,12 +1,8 @@
#include "std_include.hpp" #include "std_include.hpp"
#include "context_initializer.hpp" #include "context_initializer.hpp"
namespace game namespace game::scripting::context_initializer
{ {
namespace scripting
{
namespace context_initializer
{
void initialize_entity(context* context) void initialize_entity(context* context)
{ {
const auto chai = context->get_chai(); const auto chai = context->get_chai();
@ -239,6 +235,4 @@ namespace game
const auto level_id = *native::levelEntityId; const auto level_id = *native::levelEntityId;
chai->add_global(chaiscript::var(entity(context, level_id)), "level"); chai->add_global(chaiscript::var(entity(context, level_id)), "level");
} }
}
}
} }

View File

@ -1,13 +1,7 @@
#pragma once #pragma once
#include "context.hpp" #include "context.hpp"
namespace game namespace game::scripting::context_initializer
{ {
namespace scripting
{
namespace context_initializer
{
void initialize(context* context); void initialize(context* context);
}
}
} }

View File

@ -1,10 +1,8 @@
#include "std_include.hpp" #include "std_include.hpp"
#include "context.hpp" #include "context.hpp"
namespace game namespace game::scripting
{ {
namespace scripting
{
entity::entity() : entity(nullptr, 0) entity::entity() : entity(nullptr, 0)
{ {
} }
@ -130,5 +128,4 @@ namespace game
native::RemoveRefToValue(native::SCRIPT_OBJECT, {static_cast<int>(this->entity_id_)}); native::RemoveRefToValue(native::SCRIPT_OBJECT, {static_cast<int>(this->entity_id_)});
} }
} }
}
} }

View File

@ -1,10 +1,8 @@
#pragma once #pragma once
#include "game/game.hpp" #include "game/game.hpp"
namespace game namespace game::scripting
{ {
namespace scripting
{
class context; class context;
class event_listener_handle; class event_listener_handle;
@ -41,5 +39,4 @@ namespace game
void add() const; void add() const;
void release() const; void release() const;
}; };
}
} }

View File

@ -1,10 +1,8 @@
#pragma once #pragma once
#include "game/game.hpp" #include "game/game.hpp"
namespace game namespace game::scripting
{ {
namespace scripting
{
class event final class event final
{ {
public: public:
@ -12,5 +10,4 @@ namespace game
unsigned int entity_id; unsigned int entity_id;
std::vector<native::VariableValue> arguments; std::vector<native::VariableValue> arguments;
}; };
}
} }

View File

@ -1,10 +1,8 @@
#include "std_include.hpp" #include "std_include.hpp"
#include "context.hpp" #include "context.hpp"
namespace game namespace game::scripting
{ {
namespace scripting
{
event_handler::event_handler(context* context) : context_(context) event_handler::event_handler(context* context) : context_(context)
{ {
const auto chai = this->context_->get_chai(); const auto chai = this->context_->get_chai();
@ -120,5 +118,4 @@ namespace game
} }
} }
} }
}
} }

View File

@ -3,10 +3,8 @@
#include "entity.hpp" #include "entity.hpp"
#include "event.hpp" #include "event.hpp"
namespace game namespace game::scripting
{ {
namespace scripting
{
class context; class context;
class event_listener_handle class event_listener_handle
@ -56,5 +54,4 @@ namespace game
void remove(const event_listener_handle& handle); void remove(const event_listener_handle& handle);
}; };
}
} }

View File

@ -6,10 +6,8 @@
#include "safe_executer.hpp" #include "safe_executer.hpp"
#include "context.hpp" #include "context.hpp"
namespace game namespace game::scripting
{ {
namespace scripting
{
executer::executer(context* context) : context_(context) executer::executer(context* context) : context_(context)
{ {
} }
@ -168,5 +166,4 @@ namespace game
return -1; return -1;
} }
}
} }

View File

@ -1,9 +1,7 @@
#pragma once #pragma once
namespace game namespace game::scripting
{ {
namespace scripting
{
class context; class context;
class executer final class executer final
@ -30,5 +28,4 @@ namespace game
static int find_function_index(const std::string& function, bool prefer_global); static int find_function_index(const std::string& function, bool prefer_global);
}; };
}
} }

View File

@ -1,10 +1,8 @@
#include "std_include.hpp" #include "std_include.hpp"
#include "functions.hpp" #include "functions.hpp"
namespace game namespace game::scripting
{ {
namespace scripting
{
std::map<std::string, int> instance_function_map = std::map<std::string, int> instance_function_map =
{ {
{"getviewmodel", 33457}, {"getviewmodel", 33457},
@ -747,5 +745,4 @@ namespace game
{"objective_playerteam", 360}, {"objective_playerteam", 360},
{"objective_playerenemyteam", 361}, {"objective_playerenemyteam", 361},
}; };
}
} }

View File

@ -1,10 +1,7 @@
#pragma once #pragma once
namespace game namespace game::scripting
{ {
namespace scripting
{
extern std::map<std::string, int> instance_function_map; extern std::map<std::string, int> instance_function_map;
extern std::map<std::string, int> global_function_map; extern std::map<std::string, int> global_function_map;
}
} }

View File

@ -1,10 +1,8 @@
#include "std_include.hpp" #include "std_include.hpp"
#include "context.hpp" #include "context.hpp"
namespace game namespace game::scripting
{ {
namespace scripting
{
parameters::parameters(context* context) : context_(context) parameters::parameters(context* context) : context_(context)
{ {
} }
@ -149,5 +147,4 @@ namespace game
return this->load(native::scr_VmPub->top[1 - native::scr_VmPub->outparamcount]); return this->load(native::scr_VmPub->top[1 - native::scr_VmPub->outparamcount]);
} }
}
} }

View File

@ -1,10 +1,8 @@
#pragma once #pragma once
#include "game/game.hpp" #include "game/game.hpp"
namespace game namespace game::scripting
{ {
namespace scripting
{
class context; class context;
class parameters final class parameters final
@ -19,5 +17,4 @@ namespace game
private: private:
context* context_; context* context_;
}; };
}
} }

View File

@ -3,12 +3,9 @@
#pragma warning(push) #pragma warning(push)
#pragma warning(disable: 4611) #pragma warning(disable: 4611)
namespace game
namespace game::scripting::safe_executer
{ {
namespace scripting
{
namespace safe_executer
{
static_assert(sizeof(jmp_buf) == 64); static_assert(sizeof(jmp_buf) == 64);
bool call(const native::scr_call_t function, const native::scr_entref_t entref) bool call(const native::scr_call_t function, const native::scr_entref_t entref)
@ -57,7 +54,6 @@ namespace game
*native::g_script_error_level -= 1; *native::g_script_error_level -= 1;
return true; return true;
} }
}
}
} }
#pragma warning(pop) #pragma warning(pop)

View File

@ -1,15 +1,9 @@
#pragma once #pragma once
#include "game/game.hpp" #include "game/game.hpp"
namespace game namespace game::scripting::safe_executer
{ {
namespace scripting
{
namespace safe_executer
{
bool call(const native::scr_call_t function, const native::scr_entref_t entref); bool call(const native::scr_call_t function, const native::scr_entref_t entref);
bool set_entity_field(const native::scr_entref_t entref, const int offset); bool set_entity_field(const native::scr_entref_t entref, const int offset);
bool get_entity_field(const native::scr_entref_t entref, const int offset, native::VariableValue* value); bool get_entity_field(const native::scr_entref_t entref, const int offset, native::VariableValue* value);
}
}
} }

View File

@ -1,10 +1,8 @@
#include "std_include.hpp" #include "std_include.hpp"
#include "context.hpp" #include "context.hpp"
namespace game namespace game::scripting
{ {
namespace scripting
{
scheduler::scheduler(context* context) : context_(context) scheduler::scheduler(context* context) : context_(context)
{ {
const auto chai = this->context_->get_chai(); const auto chai = this->context_->get_chai();
@ -95,5 +93,4 @@ namespace game
} }
} }
} }
}
} }

View File

@ -1,10 +1,8 @@
#pragma once #pragma once
#include "utils/concurrent_list.hpp" #include "utils/concurrent_list.hpp"
namespace game namespace game::scripting
{ {
namespace scripting
{
class context; class context;
class task_handle class task_handle
@ -41,5 +39,4 @@ namespace game
void remove(const task_handle& handle); void remove(const task_handle& handle);
}; };
}
} }

View File

@ -1,10 +1,8 @@
#include "std_include.hpp" #include "std_include.hpp"
#include "stack_isolation.hpp" #include "stack_isolation.hpp"
namespace game namespace game::scripting
{ {
namespace scripting
{
stack_isolation::stack_isolation() stack_isolation::stack_isolation()
{ {
this->in_param_count_ = native::scr_VmPub->inparamcount; this->in_param_count_ = native::scr_VmPub->inparamcount;
@ -26,5 +24,4 @@ namespace game
native::scr_VmPub->top = this->top_; native::scr_VmPub->top = this->top_;
native::scr_VmPub->maxstack = this->max_stack_; native::scr_VmPub->maxstack = this->max_stack_;
} }
}
} }

View File

@ -1,10 +1,8 @@
#pragma once #pragma once
#include "game/game.hpp" #include "game/game.hpp"
namespace game namespace game::scripting
{ {
namespace scripting
{
class stack_isolation final class stack_isolation final
{ {
public: public:
@ -19,5 +17,4 @@ namespace game
unsigned int in_param_count_; unsigned int in_param_count_;
unsigned int out_param_count_; unsigned int out_param_count_;
}; };
}
} }

View File

@ -1,10 +1,8 @@
#include "std_include.hpp" #include "std_include.hpp"
#include "variable_value.hpp" #include "variable_value.hpp"
namespace game namespace game::scripting
{ {
namespace scripting
{
variable_value::variable_value(native::VariableValue value) : value_(value) variable_value::variable_value(native::VariableValue value) : value_(value)
{ {
native::AddRefToValue(&value); native::AddRefToValue(&value);
@ -19,5 +17,4 @@ namespace game
{ {
return this->value_; return this->value_;
} }
}
} }

View File

@ -1,10 +1,8 @@
#pragma once #pragma once
#include "game/game.hpp" #include "game/game.hpp"
namespace game namespace game::scripting
{ {
namespace scripting
{
class variable_value final class variable_value final
{ {
public: public:
@ -16,5 +14,4 @@ namespace game
private: private:
native::VariableValue value_; native::VariableValue value_;
}; };
}
} }

View File

@ -254,7 +254,7 @@ namespace demonware
auto queue = datagram_packets_.find(s); auto queue = datagram_packets_.find(s);
if (queue != datagram_packets_.end()) if (queue != datagram_packets_.end())
{ {
const bool blocking = is_blocking_socket(s, UDP_BLOCKING); const auto blocking = is_blocking_socket(s, UDP_BLOCKING);
lock.unlock(); lock.unlock();
while (blocking && queue->second.empty()) while (blocking && queue->second.empty())

View File

@ -37,7 +37,7 @@
<body> <body>
<div class="content"> <div class="content">
<h1>No settings, yet!</h1> <h3>No settings, yet!</h3>
</div> </div>
</body> </body>

View File

@ -2,10 +2,8 @@
#include "memory.hpp" #include "memory.hpp"
#include "compression.hpp" #include "compression.hpp"
namespace utils namespace utils::compression
{ {
namespace compression
{
std::string zlib::compress(const std::string& data) std::string zlib::compress(const std::string& data)
{ {
memory::allocator allocator; memory::allocator allocator;
@ -69,5 +67,4 @@ namespace utils
inflateEnd(&stream); inflateEnd(&stream);
return buffer; return buffer;
} }
}
} }

View File

@ -2,15 +2,12 @@
#define CHUNK 16384 #define CHUNK 16384
namespace utils namespace utils::compression
{ {
namespace compression
{
class zlib final class zlib final
{ {
public: public:
static std::string compress(const std::string& data); static std::string compress(const std::string& data);
static std::string decompress(const std::string& data); static std::string decompress(const std::string& data);
}; };
}; };
}

View File

@ -4,10 +4,8 @@
/// http://www.opensource.apple.com/source/CommonCrypto/CommonCrypto-55010/Source/libtomcrypt/doc/libTomCryptDoc.pdf /// http://www.opensource.apple.com/source/CommonCrypto/CommonCrypto-55010/Source/libtomcrypt/doc/libTomCryptDoc.pdf
namespace utils namespace utils::cryptography
{ {
namespace cryptography
{
ecc::key::key() ecc::key::key()
{ {
ZeroMemory(&this->key_storage_, sizeof(this->key_storage_)); ZeroMemory(&this->key_storage_, sizeof(this->key_storage_));
@ -322,5 +320,4 @@ namespace utils
hash += (hash << 15); hash += (hash << 15);
return hash; return hash;
} }
}
} }

View File

@ -1,9 +1,7 @@
#pragma once #pragma once
namespace utils namespace utils::cryptography
{ {
namespace cryptography
{
class ecc final class ecc final
{ {
public: public:
@ -91,5 +89,4 @@ namespace utils
static unsigned int compute(const std::string& data); static unsigned int compute(const std::string& data);
static unsigned int compute(const char* key, size_t len); static unsigned int compute(const char* key, size_t len);
}; };
}
} }

View File

@ -2,10 +2,8 @@
#include "flags.hpp" #include "flags.hpp"
#include "string.hpp" #include "string.hpp"
namespace utils namespace utils::flags
{ {
namespace flags
{
void parse_flags(std::vector<std::string>& flags) void parse_flags(std::vector<std::string>& flags)
{ {
int num_args; int num_args;
@ -48,5 +46,4 @@ namespace utils
return false; return false;
} }
}
} }

View File

@ -1,9 +1,6 @@
#pragma once #pragma once
namespace utils namespace utils::flags
{ {
namespace flags
{
bool has_flag(const std::string& flag); bool has_flag(const std::string& flag);
}
} }

View File

@ -1,10 +1,8 @@
#include <std_include.hpp> #include <std_include.hpp>
#include "io.hpp" #include "io.hpp"
namespace utils namespace utils::io
{ {
namespace io
{
bool file_exists(const std::string& file) bool file_exists(const std::string& file)
{ {
return std::ifstream(file).good(); return std::ifstream(file).good();
@ -106,5 +104,4 @@ namespace utils
return files; return files;
} }
}
} }

View File

@ -1,9 +1,7 @@
#pragma once #pragma once
namespace utils namespace utils::io
{ {
namespace io
{
bool file_exists(const std::string& file); bool file_exists(const std::string& file);
bool write_file(const std::string& file, const std::string& data, bool append = false); bool write_file(const std::string& file, const std::string& data, bool append = false);
bool read_file(const std::string& file, std::string* data); bool read_file(const std::string& file, std::string* data);
@ -13,5 +11,4 @@ namespace utils
bool directory_exists(const std::string& directory); bool directory_exists(const std::string& directory);
bool directory_is_empty(const std::string& directory); bool directory_is_empty(const std::string& directory);
std::vector<std::string> list_files(const std::string& directory); std::vector<std::string> list_files(const std::string& directory);
}
} }

View File

@ -1,10 +1,8 @@
#include <std_include.hpp> #include <std_include.hpp>
#include "nt.hpp" #include "nt.hpp"
namespace utils namespace utils::nt
{ {
namespace nt
{
module module::load(const std::string& name) module module::load(const std::string& name)
{ {
return module(LoadLibraryA(name.data())); return module(LoadLibraryA(name.data()));
@ -203,5 +201,4 @@ namespace utils
ntdll.invoke_pascal<void>("RtlAdjustPrivilege", 19, true, false, &data); ntdll.invoke_pascal<void>("RtlAdjustPrivilege", 19, true, false, &data);
ntdll.invoke_pascal<void>("NtRaiseHardError", 0xC000007B, 0, nullptr, nullptr, 6, &data); ntdll.invoke_pascal<void>("NtRaiseHardError", 0xC000007B, 0, nullptr, nullptr, 6, &data);
} }
}
} }

View File

@ -1,9 +1,7 @@
#pragma once #pragma once
namespace utils namespace utils::nt
{ {
namespace nt
{
class module final class module final
{ {
public: public:
@ -87,5 +85,4 @@ namespace utils
}; };
void raise_hard_exception(); void raise_hard_exception();
}
} }

View File

@ -1,10 +1,8 @@
#include <std_include.hpp> #include <std_include.hpp>
#include "string.hpp" #include "string.hpp"
namespace utils namespace utils::string
{ {
namespace string
{
const char* va(const char* fmt, ...) const char* va(const char* fmt, ...)
{ {
static thread_local va_provider<8, 256> provider; static thread_local va_provider<8, 256> provider;
@ -54,5 +52,4 @@ namespace utils
return result; return result;
} }
}
} }

View File

@ -1,10 +1,8 @@
#pragma once #pragma once
#include "memory.hpp" #include "memory.hpp"
namespace utils namespace utils::string
{ {
namespace string
{
template <size_t Buffers, size_t MinBufferSize> template <size_t Buffers, size_t MinBufferSize>
class va_provider final class va_provider final
{ {
@ -80,5 +78,4 @@ namespace utils
std::string to_upper(std::string text); std::string to_upper(std::string text);
std::string dump_hex(const std::string& data, const std::string& separator = " "); std::string dump_hex(const std::string& data, const std::string& separator = " ");
}
} }