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 "context_initializer.hpp"
namespace game
namespace game::scripting
{
namespace scripting
{
context::context() : executer_(this), scheduler_(this), parameters_(this), event_handler_(this)
{
context_initializer::initialize(this);
@ -34,5 +32,4 @@ namespace game
{
return &this->chai_;
}
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -3,12 +3,9 @@
#pragma warning(push)
#pragma warning(disable: 4611)
namespace game
namespace game::scripting::safe_executer
{
namespace scripting
{
namespace safe_executer
{
static_assert(sizeof(jmp_buf) == 64);
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;
return true;
}
}
}
}
#pragma warning(pop)

View File

@ -1,15 +1,9 @@
#pragma once
#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 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);
}
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -254,7 +254,7 @@ namespace demonware
auto queue = datagram_packets_.find(s);
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();
while (blocking && queue->second.empty())

View File

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

View File

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

View File

@ -2,15 +2,12 @@
#define CHUNK 16384
namespace utils
namespace utils::compression
{
namespace compression
{
class zlib final
{
public:
static std::string compress(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
namespace utils
namespace utils::cryptography
{
namespace cryptography
{
ecc::key::key()
{
ZeroMemory(&this->key_storage_, sizeof(this->key_storage_));
@ -322,5 +320,4 @@ namespace utils
hash += (hash << 15);
return hash;
}
}
}

View File

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

View File

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

View File

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

View File

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

View File

@ -1,9 +1,7 @@
#pragma once
namespace utils
namespace utils::io
{
namespace io
{
bool file_exists(const std::string& file);
bool write_file(const std::string& file, const std::string& data, bool append = false);
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_is_empty(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 "nt.hpp"
namespace utils
namespace utils::nt
{
namespace nt
{
module module::load(const std::string& name)
{
return module(LoadLibraryA(name.data()));
@ -203,5 +201,4 @@ namespace utils
ntdll.invoke_pascal<void>("RtlAdjustPrivilege", 19, true, false, &data);
ntdll.invoke_pascal<void>("NtRaiseHardError", 0xC000007B, 0, nullptr, nullptr, 6, &data);
}
}
}

View File

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

View File

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

View File

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