<commit_before>#include <SDL.h>
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
#include <functional>
#include <algorithm>
#include <lua.hpp>
#include <LuaBridge.h>
#include "types.h"
#include "wrappers.h"
#include "auxiliary.h"
#include "entity.h"
#include "commands.h"
#include "player.h"

using namespace te;

namespace te
{
    class LuaGameState
    {
    public:
        LuaGameState(const std::string& filename = "init.lua")
            : mpL(luaL_newstate(), [](lua_State* L){ lua_close(L); })
            , mHandleCount(0)
            , mEntities()
            , mPositionMap()
            , mVelocityMap()
            , mBoundingBoxMap()
            , mDimensionMap()
        {
            lua_State* pL = mpL.get();
            luaL_openlibs(pL);

            luabridge::getGlobalNamespace(pL)
                .beginClass<LuaGameState>("GameState")
                .addFunction("createEntity", &LuaGameState::createEntity)
                .addFunction("setBoundingBox", &LuaGameState::setBoundingBox)
                .addFunction("setSprite", &LuaGameState::setSprite)
                .addFunction("destroyEntity", &LuaGameState::destroyEntity)
                .endClass();
            luabridge::push(pL, this);
            lua_setglobal(pL, "game");

            luaL_dofile(pL, filename.c_str());
            luabridge::getGlobal(pL, "main")();
        }

        typedef unsigned int EntityHandle;

        EntityHandle createEntity(float x, float y, float dx, float dy)
        {
            EntityHandle handle = mHandleCount++;
            mEntities.push_back(handle);
            mPositionMap.insert(std::make_pair(handle, Vector2f(x, y)));
            mVelocityMap.insert(std::make_pair(handle, Vector2f(dx, dy)));
            return handle;
        }

        void setBoundingBox(EntityHandle handle, int width, int height)
        {
            if (!exists(handle)) return;

            insertOrAssign(mBoundingBoxMap, std::make_pair(
               handle, Vector2i(width, height)));
        }

        void setSprite(EntityHandle handle, int width, int height)
        {
            if (!exists(handle)) return;<commit_msg>Guarantee a bounding box on construction<commit_after>#include <SDL.h>
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
#include <functional>
#include <algorithm>
#include <lua.hpp>
#include <LuaBridge.h>
#include "types.h"
#include "wrappers.h"
#include "auxiliary.h"
#include "entity.h"
#include "commands.h"
#include "player.h"

using namespace te;

namespace te
{
    class LuaGameState
    {
    public:
        LuaGameState(const std::string& filename = "init.lua")
            : mpL(luaL_newstate(), [](lua_State* L){ lua_close(L); })
            , mHandleCount(0)
            , mEntities()
            , mPositionMap()
            , mVelocityMap()
            , mBoundingBoxMap()
            , mDimensionMap()
        {
            lua_State* pL = mpL.get();
            luaL_openlibs(pL);

            luabridge::getGlobalNamespace(pL)
                .beginClass<LuaGameState>("GameState")
                .addFunction("createEntity", &LuaGameState::createEntity)
                .addFunction("setBoundingBox", &LuaGameState::setBoundingBox)
                .addFunction("setSprite", &LuaGameState::setSprite)
                .addFunction("destroyEntity", &LuaGameState::destroyEntity)
                .endClass();
            luabridge::push(pL, this);
            lua_setglobal(pL, "game");

            luaL_dofile(pL, filename.c_str());
            luabridge::getGlobal(pL, "main")();
        }

        typedef unsigned int EntityHandle;

        EntityHandle createEntity(float x, float y, float dx, float dy)
        {
            EntityHandle handle = mHandleCount++;
            mEntities.push_back(handle);
            mPositionMap.insert(std::make_pair(handle, Vector2f(x, y)));
            mVelocityMap.insert(std::make_pair(handle, Vector2f(dx, dy)));
            mBoundingBoxMap.insert(std::make_pair(handle, Vector2i(0, 0)));
            return handle;
        }

        void setBoundingBox(EntityHandle handle, int width, int height)
        {
            if (!exists(handle)) return;

            auto it = mBoundingBoxMap.find(handle);
            it->second = Vector2i(width, height);
        }

        void setSprite(EntityHandle handle, int width, int height)
        {
            if (!exists(handle)) return;
{'fraction_non_alphanumeric': 0.1253664036076663, 'fraction_numerical': 0.002480270574971815, 'mean_word_length': 2.31044776119403, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 24, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '478058', 'n_tokens_mistral': 1361, 'n_tokens_neox': 1329, 'n_words': 258}