diff --git a/doc/samples/btphystest.h b/doc/samples/btphystest.h index 26ba2112..8d44d0b5 100644 --- a/doc/samples/btphystest.h +++ b/doc/samples/btphystest.h @@ -43,7 +43,7 @@ public: BtPhysTest(bool editor = false); virtual ~BtPhysTest(); - char const *GetName() { return ""; } + std::string GetName() const { return ""; } protected: virtual void TickGame(float seconds); diff --git a/doc/samples/meshviewer/scenesetup.h b/doc/samples/meshviewer/scenesetup.h index 23c36c25..9d20284d 100644 --- a/doc/samples/meshviewer/scenesetup.h +++ b/doc/samples/meshviewer/scenesetup.h @@ -36,7 +36,7 @@ public: SceneSetup(std::string const& name); ~SceneSetup(); - static char const *GetName() { return ""; } + static std::string GetName() { return ""; } //-- bool Startup(); diff --git a/doc/samples/nacl_phystest.h b/doc/samples/nacl_phystest.h index 8b5707fd..2665f8bb 100644 --- a/doc/samples/nacl_phystest.h +++ b/doc/samples/nacl_phystest.h @@ -1,8 +1,14 @@ // -// BtPhysTest +// Lol Engine — Bullet physics test // -// Copyright: (c) 2009-2013 Benjamin "Touky" Huet -// (c) 2012 Sam Hocevar +// Copyright © 2009—2013 Benjamin “Touky” Huet +// © 2012—2018 Sam Hocevar +// +// Lol Engine is free software. It comes without any warranty, to +// the extent permitted by applicable law. You can redistribute it +// and/or modify it under the terms of the Do What the Fuck You Want +// to Public License, Version 2, as published by the WTFPL Task Force. +// See http://www.wtfpl.net/ for more details. // #pragma once @@ -13,7 +19,7 @@ public: Nacl_PhysTest(bool editor = false); virtual ~Nacl_PhysTest(); - char const *GetName() { return ""; } + std::string GetName() const { return ""; } protected: virtual void TickGame(float seconds); diff --git a/doc/samples/physicobject.h b/doc/samples/physicobject.h index 1e7c7e7b..479f24f4 100644 --- a/doc/samples/physicobject.h +++ b/doc/samples/physicobject.h @@ -1,11 +1,15 @@ // -// Orbital +// Lol Engine — Bullet physics test // // Copyright © 2009—2013 Cédric Lecacheur // © 2009—2013 Benjamin “Touky” Huet -// © 2012—2015 Sam Hocevar +// © 2012—2018 Sam Hocevar // -// No licensing terms yet. All rights reserved. +// Lol Engine is free software. It comes without any warranty, to +// the extent permitted by applicable law. You can redistribute it +// and/or modify it under the terms of the Do What the Fuck You Want +// to Public License, Version 2, as published by the WTFPL Task Force. +// See http://www.wtfpl.net/ for more details. // #pragma once @@ -141,13 +145,13 @@ public: if (!MeshRand.count()) { - array colors_base = { "#add", "#dad", "#dda", "#daa", "#ada", "#aad" }; + array colors_base = { "#add", "#dad", "#dda", "#daa", "#ada", "#aad" }; MeshLimit << 0; #if USE_BOX { - array colors = colors_base; + array colors = colors_base; while (colors.count()) { EasyMesh m; @@ -196,7 +200,7 @@ public: MeshRand << "[tpbn tvnc sc#aaff aq 0 0]"; #else { - array colors = colors_base; + array colors = colors_base; while (colors.count()) { EasyMesh m; @@ -220,7 +224,7 @@ public: #if USE_CONE { - array colors = colors_base; + array colors = colors_base; while (colors.count()) { EasyMesh m; @@ -247,7 +251,7 @@ public: #if USE_CYLINDER { - array colors = colors_base; + array colors = colors_base; while (colors.count()) { EasyMesh m; @@ -275,7 +279,7 @@ public: #if USE_CAPSULE { - array colors = colors_base; + array colors = colors_base; while (colors.count()) { EasyMesh m; @@ -395,7 +399,7 @@ public: { } - char const *GetName() { return ""; } + std::string GetName() const { return ""; } protected: virtual void TickGame(float seconds) diff --git a/doc/samples/physics/easycharactercontroller.cpp b/doc/samples/physics/easycharactercontroller.cpp index 8afaa3a6..f8c98812 100644 --- a/doc/samples/physics/easycharactercontroller.cpp +++ b/doc/samples/physics/easycharactercontroller.cpp @@ -1,13 +1,14 @@ // -// Lol Engine +// Lol Engine — Bullet physics test // -// Copyright: (c) 2010-2013 Sam Hocevar -// (c) 2009-2013 Cédric Lecacheur -// (c) 2009-2013 Benjamin "Touky" Huet -// This program is free software; you can redistribute it and/or -// modify it under the terms of the Do What The Fuck You Want To -// Public License, Version 2, as published by Sam Hocevar. See -// http://www.wtfpl.net/ for more details. +// Copyright © 2009—2013 Benjamin “Touky” Huet +// © 2010—2018 Sam Hocevar +// +// Lol Engine is free software. It comes without any warranty, to +// the extent permitted by applicable law. You can redistribute it +// and/or modify it under the terms of the Do What the Fuck You Want +// to Public License, Version 2, as published by the WTFPL Task Force. +// See http://www.wtfpl.net/ for more details. // #if HAVE_CONFIG_H @@ -125,7 +126,7 @@ void EasyCharacterController::BaseTransformChanged(const lol::mat4& PreviousMatr } //--- -char const *EasyCharacterController::GetName() +std::string EasyCharacterController::GetName() { return ""; } diff --git a/doc/samples/physics/easycharactercontroller.h b/doc/samples/physics/easycharactercontroller.h index 717c3a88..2968f32f 100644 --- a/doc/samples/physics/easycharactercontroller.h +++ b/doc/samples/physics/easycharactercontroller.h @@ -1,10 +1,10 @@ // -// Lol Engine +// Lol Engine — Bullet physics test // -// Copyright © 2009—2015 Benjamin “Touky” Huet -// © 2010—2015 Sam Hocevar +// Copyright © 2009—2013 Benjamin “Touky” Huet +// © 2012—2018 Sam Hocevar // -// This library is free software. It comes without any warranty, to +// Lol Engine is free software. It comes without any warranty, to // the extent permitted by applicable law. You can redistribute it // and/or modify it under the terms of the Do What the Fuck You Want // to Public License, Version 2, as published by the WTFPL Task Force. @@ -69,9 +69,11 @@ public: virtual void Jump(); virtual void SetTransform(const lol::vec3& base_location, const lol::quat& base_rotation); + protected: virtual void BaseTransformChanged(const lol::mat4& PreviousMatrix, const lol::mat4& NewMatrix); - virtual char const *GetName(); + virtual std::string GetName(); + public: virtual void TickGame(float seconds); diff --git a/doc/samples/physics/lolphysics.h b/doc/samples/physics/lolphysics.h index 1167368d..f96fe80b 100644 --- a/doc/samples/physics/lolphysics.h +++ b/doc/samples/physics/lolphysics.h @@ -1,10 +1,10 @@ // -// Lol Engine +// Lol Engine — Bullet physics test // -// Copyright © 2012—2015 Sam Hocevar -// © 2009—2013 Benjamin “Touky” Huet +// Copyright © 2009—2013 Benjamin “Touky” Huet +// © 2012—2018 Sam Hocevar // -// This library is free software. It comes without any warranty, to +// Lol Engine is free software. It comes without any warranty, to // the extent permitted by applicable law. You can redistribute it // and/or modify it under the terms of the Do What the Fuck You Want // to Public License, Version 2, as published by the WTFPL Task Force. @@ -83,7 +83,7 @@ public: Exit(); } - char const *GetName() { return ""; } + std::string GetName() const { return ""; } public: void Init() diff --git a/doc/tutorial/14_lol_lua.cpp b/doc/tutorial/14_lol_lua.cpp index 958373ca..e5ecb6d1 100644 --- a/doc/tutorial/14_lol_lua.cpp +++ b/doc/tutorial/14_lol_lua.cpp @@ -2,6 +2,7 @@ // Lol Engine — Lua tutorial // // Copyright © 2014—2017 Benjamin “Touky” Huet +// © 2017—2018 Sam Hocevar // // Lol Engine is free software. It comes without any warranty, to // the extent permitted by applicable law. You can redistribute it @@ -113,7 +114,7 @@ public: static int GlobalAddString(lua_State* l) { auto stack = LuaStack::Begin(l); - auto s = stack.Get(); + auto s = stack.Get(); s += "_added"; @@ -185,10 +186,10 @@ public: float testvalue_num = demo_loader->Get("testvalue_num"); int32_t testvalue_int = demo_loader->Get("testvalue_int"); uint32_t testvalue_uint = demo_loader->Get("testvalue_uint"); - String testvalue_str = demo_loader->Get("testvalue_str"); + std::string testvalue_str = demo_loader->Get("testvalue_str"); //Grab string modified with function - String function_return = demo_loader->Get("function_return"); + std::string function_return = demo_loader->Get("function_return"); //Grab global values modified with DemoObject int32_t loluademo_return = demo_loader->Get("loluademo_return"); @@ -198,10 +199,10 @@ public: msg::info("Lua Vars: \ testvalue_num: %.2f, testvalue_int: %i, testvalue_uint: %i, testvalue_str: %s.\n", - testvalue_num, testvalue_int, testvalue_uint, testvalue_str.C()); + testvalue_num, testvalue_int, testvalue_uint, testvalue_str.c_str()); msg::info("Lua Vars: \ function_return: %s, loluademo_return: %i, loluademo_inst_return: %.2f, loluademo_getx: %i, loluademo_inst->m_x: %i.\n", - function_return.C(), loluademo_return, loluademo_inst_return, loluademo_getx, loluademo_inst->m_x); + function_return.c_str(), loluademo_return, loluademo_inst_return, loluademo_getx, loluademo_inst->m_x); #define /***/ _LOLUA_ARG_1(a00) (float)a00 #define /***/ _LOLUA_ARG_2(a00, a01) _LOLUA_ARG_1(a00), _LOLUA_ARG_1(a01) diff --git a/src/audio/sample.cpp b/src/audio/sample.cpp index a3e803d2..a19c87e9 100644 --- a/src/audio/sample.cpp +++ b/src/audio/sample.cpp @@ -86,9 +86,9 @@ void sample::TickGame(float seconds) Entity::TickGame(seconds); } -char const *sample::GetName() +std::string sample::GetName() const { - return data->m_name.c_str(); + return data->m_name; } void sample::play() diff --git a/src/camera.h b/src/camera.h index 762cd5a4..55f997bb 100644 --- a/src/camera.h +++ b/src/camera.h @@ -1,11 +1,13 @@ // -// Lol Engine +// Lol Engine // -// Copyright: (c) 2010-2013 Sam Hocevar -// This program is free software; you can redistribute it and/or -// modify it under the terms of the Do What The Fuck You Want To -// Public License, Version 2, as published by Sam Hocevar. See -// http://www.wtfpl.net/ for more details. +// Copyright © 2010—2018 Sam Hocevar +// +// Lol Engine is free software. It comes without any warranty, to +// the extent permitted by applicable law. You can redistribute it +// and/or modify it under the terms of the Do What the Fuck You Want +// to Public License, Version 2, as published by the WTFPL Task Force. +// See http://www.wtfpl.net/ for more details. // #pragma once @@ -28,7 +30,7 @@ public: Camera(); ~Camera(); - char const *GetName() { return ""; } + std::string GetName() const { return ""; } //View functions void SetView(mat4 const &view); diff --git a/src/debug/record.cpp b/src/debug/record.cpp index add3fca9..f1ed8766 100644 --- a/src/debug/record.cpp +++ b/src/debug/record.cpp @@ -1,11 +1,13 @@ // -// Lol Engine +// Lol Engine // -// Copyright: (c) 2010-2013 Sam Hocevar -// This program is free software; you can redistribute it and/or -// modify it under the terms of the Do What The Fuck You Want To -// Public License, Version 2, as published by Sam Hocevar. See -// http://www.wtfpl.net/ for more details. +// Copyright © 2010—2018 Sam Hocevar +// +// Lol Engine is free software. It comes without any warranty, to +// the extent permitted by applicable law. You can redistribute it +// and/or modify it under the terms of the Do What the Fuck You Want +// to Public License, Version 2, as published by the WTFPL Task Force. +// See http://www.wtfpl.net/ for more details. // #include @@ -30,7 +32,7 @@ class DebugRecordData friend class DebugRecord; private: - String m_path; + std::string m_path; ivec2 m_size; int m_fps; #if defined USE_PIPI @@ -42,7 +44,7 @@ private: * Public DebugRecord class */ -DebugRecord::DebugRecord(String const &path, float fps) +DebugRecord::DebugRecord(std::string const &path, float fps) : m_data(new DebugRecordData()) { Ticker::StartRecording(); diff --git a/src/debug/record.h b/src/debug/record.h index 04525542..c925a985 100644 --- a/src/debug/record.h +++ b/src/debug/record.h @@ -1,11 +1,13 @@ // -// Lol Engine +// Lol Engine // -// Copyright: (c) 2010-2013 Sam Hocevar -// This program is free software; you can redistribute it and/or -// modify it under the terms of the Do What The Fuck You Want To -// Public License, Version 2, as published by Sam Hocevar. See -// http://www.wtfpl.net/ for more details. +// Copyright © 2010—2018 Sam Hocevar +// +// Lol Engine is free software. It comes without any warranty, to +// the extent permitted by applicable law. You can redistribute it +// and/or modify it under the terms of the Do What the Fuck You Want +// to Public License, Version 2, as published by the WTFPL Task Force. +// See http://www.wtfpl.net/ for more details. // #pragma once @@ -25,7 +27,7 @@ class DebugRecordData; class DebugRecord : public Entity { public: - DebugRecord(String const &path, float fps); + DebugRecord(std::string const &path, float fps); virtual ~DebugRecord(); protected: diff --git a/src/dict.cpp b/src/dict.cpp index c91655a7..bac70d57 100644 --- a/src/dict.cpp +++ b/src/dict.cpp @@ -1,7 +1,7 @@ // // Lol Engine // -// Copyright © 2010—2015 Sam Hocevar +// Copyright © 2010—2018 Sam Hocevar // // Lol Engine is free software. It comes without any warranty, to // the extent permitted by applicable law. You can redistribute it @@ -64,7 +64,7 @@ Dict::~Dict() delete data; } -int Dict::MakeSlot(char const *name) +int Dict::MakeSlot(std::string const &name) { int slotid, empty = -1; @@ -80,7 +80,7 @@ int Dict::MakeSlot(char const *name) } else { - char const *oldname = e->GetName(); + char const *oldname = e->GetName().c_str(); if (*oldname == '<') { while (*oldname && *oldname != '>') @@ -91,7 +91,7 @@ int Dict::MakeSlot(char const *name) oldname++; } - if (!strcasecmp(name, oldname)) + if (!strcasecmp(name.c_str(), oldname)) break; } } @@ -137,7 +137,7 @@ void Dict::RemoveSlot(Entity *entity) #if !LOL_BUILD_RELEASE msg::error("removing unregistered entity %p (%s)\n", - entity, entity->GetName()); + entity, entity->GetName().c_str()); #endif } diff --git a/src/dict.h b/src/dict.h index 4593067b..0a6a8b3d 100644 --- a/src/dict.h +++ b/src/dict.h @@ -1,11 +1,13 @@ // -// Lol Engine +// Lol Engine // -// Copyright: (c) 2010-2011 Sam Hocevar -// This program is free software; you can redistribute it and/or -// modify it under the terms of the Do What The Fuck You Want To -// Public License, Version 2, as published by Sam Hocevar. See -// http://www.wtfpl.net/ for more details. +// Copyright © 2010—2018 Sam Hocevar +// +// Lol Engine is free software. It comes without any warranty, to +// the extent permitted by applicable law. You can redistribute it +// and/or modify it under the terms of the Do What the Fuck You Want +// to Public License, Version 2, as published by the WTFPL Task Force. +// See http://www.wtfpl.net/ for more details. // #pragma once @@ -28,7 +30,7 @@ public: Dict(); ~Dict(); - int MakeSlot(char const *name); + int MakeSlot(std::string const &name); void RemoveSlot(int slotid); void RemoveSlot(Entity *entity); diff --git a/src/easymesh/easymesh.h b/src/easymesh/easymesh.h index aa429d5a..145c92d8 100644 --- a/src/easymesh/easymesh.h +++ b/src/easymesh/easymesh.h @@ -41,7 +41,7 @@ struct CSGUsageBase : public StructSafeEnum Xor }; protected: - virtual bool BuildEnumMap(std::map& enum_map) + virtual bool BuildEnumMap(std::map& enum_map) { enum_map[Union] = "Union"; enum_map[Substract] = "Substract"; @@ -65,7 +65,7 @@ struct MeshTransformBase : public StructSafeEnum Shear }; protected: - virtual bool BuildEnumMap(std::map& enum_map) + virtual bool BuildEnumMap(std::map& enum_map) { enum_map[Taper] = "Taper"; enum_map[Twist] = "Twist"; diff --git a/src/easymesh/easymeshbuild.h b/src/easymesh/easymeshbuild.h index b3d66f11..0eb4390f 100644 --- a/src/easymesh/easymeshbuild.h +++ b/src/easymesh/easymeshbuild.h @@ -38,7 +38,7 @@ struct MeshBuildOperationBase : public StructSafeEnum All = 0xffff, }; protected: - virtual bool BuildEnumMap(std::map& enum_map) + virtual bool BuildEnumMap(std::map& enum_map) { enum_map[ScaleWinding] = "ScaleWinding"; enum_map[CommandRecording] = "CommandRecording"; @@ -99,7 +99,7 @@ struct EasyMeshCmdTypeBase : public StructSafeEnum AppendCog, }; protected: - virtual bool BuildEnumMap(std::map& enum_map) + virtual bool BuildEnumMap(std::map& enum_map) { enum_map[MeshCsg] = "MeshCsg"; enum_map[LoopStart] = "LoopStart"; @@ -160,7 +160,7 @@ struct MeshTypeBase : public StructSafeEnum MAX }; protected: - virtual bool BuildEnumMap(std::map& enum_map) + virtual bool BuildEnumMap(std::map& enum_map) { enum_map[Triangle] = "Triangle"; enum_map[Quad] = "Quad"; @@ -200,7 +200,7 @@ struct TexCoordBuildTypeBase : public StructSafeEnum Max }; protected: - virtual bool BuildEnumMap(std::map& enum_map) + virtual bool BuildEnumMap(std::map& enum_map) { enum_map[TriangleDefault] = "TriangleDefault"; enum_map[QuadDefault] = "QuadDefault"; @@ -235,7 +235,7 @@ struct MeshFaceTypeBase : public StructSafeEnum MAX }; protected: - virtual bool BuildEnumMap(std::map& enum_map) + virtual bool BuildEnumMap(std::map& enum_map) { enum_map[BoxFront] = "BoxFront"; enum_map[QuadDefault] = "QuadDefault"; @@ -261,7 +261,7 @@ struct TexCoordPosBase : public StructSafeEnum TR // Top Right }; protected: - virtual bool BuildEnumMap(std::map& enum_map) + virtual bool BuildEnumMap(std::map& enum_map) { enum_map[BL] = "BL"; enum_map[BR] = "BR"; @@ -512,7 +512,7 @@ struct VDictTypeBase : public StructSafeEnum Master = -1, }; protected: - virtual bool BuildEnumMap(std::map& enum_map) + virtual bool BuildEnumMap(std::map& enum_map) { enum_map[DoesNotExist] = "DoesNotExist"; enum_map[Alone] = "Alone"; diff --git a/src/easymesh/easymeshrender.cpp b/src/easymesh/easymeshrender.cpp index 3ef237fd..7040b965 100644 --- a/src/easymesh/easymeshrender.cpp +++ b/src/easymesh/easymeshrender.cpp @@ -2,7 +2,7 @@ // Lol Engine // // Copyright © 2009—2013 Benjamin “Touky” Huet -// © 2010—2017 Sam Hocevar +// © 2010—2018 Sam Hocevar // © 2009—2013 Cédric Lecacheur // // Lol Engine is free software. It comes without any warranty, to @@ -93,9 +93,9 @@ GpuShaderData::~GpuShaderData() } //----------------------------------------------------------------------------- -void GpuShaderData::AddUniform(const lol::String &new_uniform) +void GpuShaderData::AddUniform(std::string const &new_uniform) { - m_shader_uniform.push(new_uniform, m_shader->GetUniformLocation(new_uniform.C())); + m_shader_uniform.push(new_uniform, m_shader->GetUniformLocation(new_uniform)); } //----------------------------------------------------------------------------- @@ -105,7 +105,7 @@ void GpuShaderData::AddAttribute(VertexUsage usage, int index) } //----------------------------------------------------------------------------- -ShaderUniform const *GpuShaderData::GetUniform(const lol::String &uniform) +ShaderUniform const *GpuShaderData::GetUniform(std::string const &uniform) { for (int i = 0; i < m_shader_uniform.count(); ++i) if (m_shader_uniform[i].m1 == uniform) @@ -159,17 +159,18 @@ DefaultShaderData::DefaultShaderData(uint16_t vert_decl_flags, Shader* shader, b SetupDefaultData(with_UV); } -static const String DefaultUniforms[8] = +static std::string const DefaultUniforms[8] = { - String("u_lights"), - String("u_model"), - String("u_modelview"), - String("u_view"), - String("u_inv_view"), - String("u_proj"), - String("u_normalmat"), - String("u_damage") + "u_lights", + "u_model", + "u_modelview", + "u_view", + "u_inv_view", + "u_proj", + "u_normalmat", + "u_damage", }; + //----------------------------------------------------------------------------- void DefaultShaderData::StoreUniformNames() { diff --git a/src/easymesh/easymeshrender.h b/src/easymesh/easymeshrender.h index 97585e4d..0de84341 100644 --- a/src/easymesh/easymeshrender.h +++ b/src/easymesh/easymeshrender.h @@ -2,7 +2,7 @@ // Lol Engine // // Copyright © 2009—2013 Benjamin “Touky” Huet -// © 2010—2017 Sam Hocevar +// © 2010—2018 Sam Hocevar // © 2009—2013 Cédric Lecacheur // // Lol Engine is free software. It comes without any warranty, to @@ -14,6 +14,7 @@ #pragma once +#include #include namespace lol @@ -31,7 +32,7 @@ struct MeshRenderBase : public StructSafeEnum IgnoreRender, }; protected: - virtual bool BuildEnumMap(std::map& enum_map) + virtual bool BuildEnumMap(std::map& enum_map) { enum_map[NeedData] = "NeedData"; enum_map[NeedConvert] = "NeedConvert"; @@ -81,20 +82,20 @@ public: GpuShaderData(uint16_t vert_decl_flags, Shader* shader, DebugRenderMode render_mode); virtual ~GpuShaderData(); //-- - void AddUniform(const lol::String &new_uniform); + void AddUniform(std::string const &new_uniform); void AddAttribute(VertexUsage usage, int index); - ShaderUniform const *GetUniform(const lol::String &uniform); + ShaderUniform const *GetUniform(std::string const &uniform); ShaderAttrib const *GetAttribute(VertexUsage usage, int index); //-- virtual void SetupShaderDatas(mat4 const &model) { UNUSED(model); } //-- protected: - uint16_t m_vert_decl_flags; - Shader* m_shader; - int m_render_mode; - array m_shader_uniform; - array m_shader_attrib; + uint16_t m_vert_decl_flags; + Shader *m_shader; + int m_render_mode; + array m_shader_uniform; + array m_shader_attrib; }; class DefaultShaderData : public GpuShaderData @@ -109,7 +110,7 @@ public: void SetupDefaultData(bool with_UV); virtual void SetupShaderDatas(mat4 const &model); //-- - array m_uniform_names; + array m_uniform_names; }; class GpuEasyMeshData diff --git a/src/engine/entity.cpp b/src/engine/entity.cpp index caa07239..81b70deb 100644 --- a/src/engine/entity.cpp +++ b/src/engine/entity.cpp @@ -1,7 +1,7 @@ // // Lol Engine // -// Copyright © 2010—2015 Sam Hocevar +// Copyright © 2010—2018 Sam Hocevar // // Lol Engine is free software. It comes without any warranty, to // the extent permitted by applicable law. You can redistribute it @@ -44,7 +44,7 @@ Entity::~Entity() #endif } -char const *Entity::GetName() +std::string Entity::GetName() const { return ""; } diff --git a/src/engine/entity.h b/src/engine/entity.h index 8f2ad402..274cf21c 100644 --- a/src/engine/entity.h +++ b/src/engine/entity.h @@ -1,7 +1,7 @@ // // Lol Engine // -// Copyright © 2010—2015 Sam Hocevar +// Copyright © 2010—2018 Sam Hocevar // // Lol Engine is free software. It comes without any warranty, to // the extent permitted by applicable law. You can redistribute it @@ -50,7 +50,7 @@ class Entity friend class Emcee; public: - virtual char const *GetName(); + virtual std::string GetName() const; inline bool IsTicked() { return !!m_ref && !m_autorelease; } protected: diff --git a/src/engine/ticker.cpp b/src/engine/ticker.cpp index 25b95d95..17632136 100644 --- a/src/engine/ticker.cpp +++ b/src/engine/ticker.cpp @@ -1,7 +1,7 @@ // // Lol Engine // -// Copyright © 2010—2017 Sam Hocevar +// Copyright © 2010—2018 Sam Hocevar // // Lol Engine is free software. It comes without any warranty, to // the extent permitted by applicable law. You can redistribute it @@ -114,7 +114,7 @@ void Ticker::Ref(Entity *entity) ASSERT(entity, "dereferencing nullptr entity\n"); ASSERT(!entity->m_destroy, "referencing entity scheduled for destruction %s\n", - entity->GetName()); + entity->GetName().c_str()); if (entity->m_autorelease) { @@ -139,9 +139,9 @@ int Ticker::Unref(Entity *entity) { ASSERT(entity, "dereferencing null entity\n"); ASSERT(entity->m_ref > 0, "dereferencing unreferenced entity %s\n", - entity->GetName()); + entity->GetName().c_str()); ASSERT(!entity->m_autorelease, "dereferencing autoreleased entity %s\n", - entity->GetName()); + entity->GetName().c_str()); return --entity->m_ref; } @@ -223,7 +223,7 @@ void TickerData::GameThreadTick() { Entity *e = data->m_list[g][i]; msg::debug(" \\-- [%p] %s (m_ref %d, destroy %d)\n", - e, e->GetName(), e->m_ref, e->m_destroy); + e, e->GetName().c_str(), e->m_ref, e->m_destroy); } } #endif @@ -276,7 +276,7 @@ void TickerData::GameThreadTick() if (e->m_ref) { #if !LOL_BUILD_RELEASE - msg::error("poking %s\n", e->GetName()); + msg::error("poking %s\n", e->GetName().c_str()); #endif e->m_ref--; n++; @@ -401,14 +401,14 @@ void TickerData::GameThreadTick() #if !LOL_BUILD_RELEASE if (e->m_tickstate != Entity::STATE_IDLE) msg::error("entity %s [%p] not idle for game tick\n", - e->GetName(), e); + e->GetName().c_str(), e); e->m_tickstate = Entity::STATE_PRETICK_GAME; #endif e->TickGame(data->deltatime); #if !LOL_BUILD_RELEASE if (e->m_tickstate != Entity::STATE_POSTTICK_GAME) msg::error("entity %s [%p] missed super game tick\n", - e->GetName(), e); + e->GetName().c_str(), e); e->m_tickstate = Entity::STATE_IDLE; #endif } @@ -455,14 +455,14 @@ void TickerData::DrawThreadTick() #if !LOL_BUILD_RELEASE if (e->m_tickstate != Entity::STATE_IDLE) msg::error("entity %s [%p] not idle for draw tick\n", - e->GetName(), e); + e->GetName().c_str(), e); e->m_tickstate = Entity::STATE_PRETICK_DRAW; #endif e->TickDraw(data->deltatime, scene); #if !LOL_BUILD_RELEASE if (e->m_tickstate != Entity::STATE_POSTTICK_DRAW) msg::error("entity %s [%p] missed super draw tick\n", - e->GetName(), e); + e->GetName().c_str(), e); e->m_tickstate = Entity::STATE_IDLE; #endif } diff --git a/src/engine/worldentity.cpp b/src/engine/worldentity.cpp index 81359d40..59a6cf11 100644 --- a/src/engine/worldentity.cpp +++ b/src/engine/worldentity.cpp @@ -1,11 +1,13 @@ // -// Lol Engine +// Lol Engine // -// Copyright: (c) 2010-2013 Sam Hocevar -// This program is free software; you can redistribute it and/or -// modify it under the terms of the Do What The Fuck You Want To -// Public License, Version 2, as published by Sam Hocevar. See -// http://www.wtfpl.net/ for more details. +// Copyright © 2010—2018 Sam Hocevar +// +// Lol Engine is free software. It comes without any warranty, to +// the extent permitted by applicable law. You can redistribute it +// and/or modify it under the terms of the Do What the Fuck You Want +// to Public License, Version 2, as published by the WTFPL Task Force. +// See http://www.wtfpl.net/ for more details. // #include @@ -32,7 +34,7 @@ WorldEntity::~WorldEntity() { } -char const *WorldEntity::GetName() +std::string WorldEntity::GetName() const { return ""; } diff --git a/src/engine/worldentity.h b/src/engine/worldentity.h index fc5c4fe8..0b8a74e4 100644 --- a/src/engine/worldentity.h +++ b/src/engine/worldentity.h @@ -1,11 +1,13 @@ // -// Lol Engine +// Lol Engine // -// Copyright: (c) 2010-2013 Sam Hocevar -// This program is free software; you can redistribute it and/or -// modify it under the terms of the Do What The Fuck You Want To -// Public License, Version 2, as published by Sam Hocevar. See -// http://www.wtfpl.net/ for more details. +// Copyright © 2010—2018 Sam Hocevar +// +// Lol Engine is free software. It comes without any warranty, to +// the extent permitted by applicable law. You can redistribute it +// and/or modify it under the terms of the Do What the Fuck You Want +// to Public License, Version 2, as published by the WTFPL Task Force. +// See http://www.wtfpl.net/ for more details. // #pragma once @@ -25,7 +27,7 @@ namespace lol class WorldEntity : public Entity { public: - virtual char const *GetName(); + virtual std::string GetName() const; public: box3 m_aabb; diff --git a/src/font.cpp b/src/font.cpp index 353d822a..8bef66d5 100644 --- a/src/font.cpp +++ b/src/font.cpp @@ -1,12 +1,14 @@ // -// Lol Engine +// Lol Engine // -// Copyright: (c) 2010-2013 Sam Hocevar -// 2013 Jean-Yves Lamoureux -// This program is free software; you can redistribute it and/or -// modify it under the terms of the Do What The Fuck You Want To -// Public License, Version 2, as published by Sam Hocevar. See -// http://www.wtfpl.net/ for more details. +// Copyright © 2010—2018 Sam Hocevar +// 2013 Jean-Yves Lamoureux +// +// Lol Engine is free software. It comes without any warranty, to +// the extent permitted by applicable law. You can redistribute it +// and/or modify it under the terms of the Do What the Fuck You Want +// to Public License, Version 2, as published by the WTFPL Task Force. +// See http://www.wtfpl.net/ for more details. // #include @@ -26,7 +28,7 @@ class FontData friend class Font; private: - String m_name; + std::string m_name; TileSet *tileset; ivec2 size; }; @@ -35,10 +37,10 @@ private: * Public Font class */ -Font::Font(char const *path) +Font::Font(std::string const &path) : data(new FontData()) { - data->m_name = String(" ") + path; + data->m_name = " " + path; data->tileset = Tiler::Register(path, ivec2::zero, ivec2(16)); data->size = data->tileset->GetTileSize(0); @@ -63,17 +65,17 @@ void Font::TickDraw(float seconds, Scene &scene) } } -char const *Font::GetName() +std::string Font::GetName() const { - return data->m_name.C(); + return data->m_name; } -void Font::Print(Scene &scene, vec3 pos, char const *str, vec2 scale, float spacing) +void Font::Print(Scene &scene, vec3 pos, std::string const &str, vec2 scale, float spacing) { float origin_x = pos.x; - while (*str) + for (int i = 0; i < (int)str.length(); ++i) { - uint32_t ch = (uint8_t)*str++; + uint32_t ch = str[i]; switch (ch) { diff --git a/src/font.h b/src/font.h index 0a93fc2f..1eedc9b4 100644 --- a/src/font.h +++ b/src/font.h @@ -1,11 +1,13 @@ // -// Lol Engine +// Lol Engine // -// Copyright: (c) 2010-2013 Sam Hocevar -// This program is free software; you can redistribute it and/or -// modify it under the terms of the Do What The Fuck You Want To -// Public License, Version 2, as published by Sam Hocevar. See -// http://www.wtfpl.net/ for more details. +// Copyright © 2010—2018 Sam Hocevar +// +// Lol Engine is free software. It comes without any warranty, to +// the extent permitted by applicable law. You can redistribute it +// and/or modify it under the terms of the Do What the Fuck You Want +// to Public License, Version 2, as published by the WTFPL Task Force. +// See http://www.wtfpl.net/ for more details. // #pragma once @@ -25,17 +27,17 @@ class FontData; class Font : public Entity { public: - Font(char const *path); + Font(std::string const &path); ~Font(); protected: /* Inherited from Entity */ - virtual char const *GetName(); + virtual std::string GetName() const; virtual void TickDraw(float seconds, Scene &scene); public: /* New methods */ - void Print(Scene &scene, vec3 pos, char const *str, vec2 scale = vec2(1.0f), float spacing = 0.0f); + void Print(Scene &scene, vec3 pos, std::string const &str, vec2 scale = vec2(1.0f), float spacing = 0.0f); ivec2 GetSize() const; private: diff --git a/src/forge.cpp b/src/forge.cpp index 0fc8d202..3aef045f 100644 --- a/src/forge.cpp +++ b/src/forge.cpp @@ -1,11 +1,13 @@ // -// Lol Engine +// Lol Engine // -// Copyright: (c) 2010-2011 Sam Hocevar -// This program is free software; you can redistribute it and/or -// modify it under the terms of the Do What The Fuck You Want To -// Public License, Version 2, as published by Sam Hocevar. See -// http://www.wtfpl.net/ for more details. +// Copyright © 2010—2018 Sam Hocevar +// +// Lol Engine is free software. It comes without any warranty, to +// the extent permitted by applicable law. You can redistribute it +// and/or modify it under the terms of the Do What the Fuck You Want +// to Public License, Version 2, as published by the WTFPL Task Force. +// See http://www.wtfpl.net/ for more details. // #include @@ -32,7 +34,7 @@ static ForgeData * const data = &forgedata; * Public Forge class */ -int Forge::Register(char const *path) +int Forge::Register(std::string const &path) { int id = data->fonts.MakeSlot(path); diff --git a/src/forge.h b/src/forge.h index de2d2f57..fa11815a 100644 --- a/src/forge.h +++ b/src/forge.h @@ -1,11 +1,13 @@ // -// Lol Engine +// Lol Engine // -// Copyright: (c) 2010-2011 Sam Hocevar -// This program is free software; you can redistribute it and/or -// modify it under the terms of the Do What The Fuck You Want To -// Public License, Version 2, as published by Sam Hocevar. See -// http://www.wtfpl.net/ for more details. +// Copyright © 2010—2018 Sam Hocevar +// +// Lol Engine is free software. It comes without any warranty, to +// the extent permitted by applicable law. You can redistribute it +// and/or modify it under the terms of the Do What the Fuck You Want +// to Public License, Version 2, as published by the WTFPL Task Force. +// See http://www.wtfpl.net/ for more details. // #pragma once @@ -24,7 +26,7 @@ namespace lol class Forge { public: - static int Register(char const *path); + static int Register(std::string const &path); static void Deregister(int id); static Font *GetFont(int id); diff --git a/src/gradient.h b/src/gradient.h index 9679c157..846b6b60 100644 --- a/src/gradient.h +++ b/src/gradient.h @@ -1,11 +1,13 @@ // -// Lol Engine +// Lol Engine // -// Copyright: (c) 2010-2013 Sam Hocevar -// This program is free software; you can redistribute it and/or -// modify it under the terms of the Do What The Fuck You Want To -// Public License, Version 2, as published by Sam Hocevar. See -// http://www.wtfpl.net/ for more details. +// Copyright © 2010—2018 Sam Hocevar +// +// Lol Engine is free software. It comes without any warranty, to +// the extent permitted by applicable law. You can redistribute it +// and/or modify it under the terms of the Do What the Fuck You Want +// to Public License, Version 2, as published by the WTFPL Task Force. +// See http://www.wtfpl.net/ for more details. // #pragma once @@ -28,7 +30,7 @@ public: Gradient(vec3 aa, vec3 bb); virtual ~Gradient(); - char const *GetName() { return ""; } + std::string GetName() const { return ""; } protected: virtual void TickGame(float seconds); diff --git a/src/image/color/color.cpp b/src/image/color/color.cpp index 0c3f9e95..0df0e37a 100644 --- a/src/image/color/color.cpp +++ b/src/image/color/color.cpp @@ -1,11 +1,13 @@ // -// Lol Engine +// Lol Engine // -// Copyright: (c) 2010-2014 Sam Hocevar -// This program is free software; you can redistribute it and/or -// modify it under the terms of the Do What The Fuck You Want To -// Public License, Version 2, as published by Sam Hocevar. See -// http://www.wtfpl.net/ for more details. +// Copyright © 2010—2018 Sam Hocevar +// +// Lol Engine is free software. It comes without any warranty, to +// the extent permitted by applicable law. You can redistribute it +// and/or modify it under the terms of the Do What the Fuck You Want +// to Public License, Version 2, as published by the WTFPL Task Force. +// See http://www.wtfpl.net/ for more details. // #include @@ -107,25 +109,25 @@ uint16_t Color::ToRGB16(vec4 c) /* * Conversion from colours to hexadecimal */ -vec4 Color::C8BppHexString(String s) +vec4 Color::C8BppHexString(std::string const &s) { - String c = s[0] == '#' ? &s[1] : s; - uint32_t tmp = std::strtol(c.C(), nullptr, 16); - if (c.count() == 3) + std::string c = s[0] == '#' ? &s[1] : s; + uint32_t tmp = std::strtol(c.c_str(), nullptr, 16); + if (c.length() == 3) { tmp = 0x11000000u * (tmp >> 8) | 0x00110000u * ((tmp >> 4) & 0xf) | 0x00001100u * (tmp & 0xf) | 0x000000ffu; } - else if (c.count() == 4) + else if (c.length() == 4) { tmp = 0x11000000u * (tmp >> 12) | 0x00110000u * ((tmp >> 8) & 0xf) | 0x00001100u * ((tmp >> 4) & 0xf) | 0x00000011u * (tmp & 0xf); } - else if (c.count() == 6) + else if (c.length() == 6) { tmp = 0xffu | 0x100u * tmp; } diff --git a/src/light.h b/src/light.h index 8fbda990..b3449ebd 100644 --- a/src/light.h +++ b/src/light.h @@ -79,7 +79,7 @@ public: Light(); ~Light(); - char const *GetName() { return ""; } + std::string GetName() const { return ""; } void SetType(LightType const &type); LightType GetType(); diff --git a/src/lol/audio/sample.h b/src/lol/audio/sample.h index e2871a61..2f5ec30d 100644 --- a/src/lol/audio/sample.h +++ b/src/lol/audio/sample.h @@ -1,7 +1,7 @@ // // Lol Engine // -// Copyright © 2010—2016 Sam Hocevar +// Copyright © 2010—2018 Sam Hocevar // // Lol Engine is free software. It comes without any warranty, to // the extent permitted by applicable law. You can redistribute it @@ -35,7 +35,7 @@ public: protected: /* Inherited from Entity */ - virtual char const *GetName(); + virtual std::string GetName() const; virtual void TickGame(float seconds); public: diff --git a/src/lol/base/string.h b/src/lol/base/string.h index 4d4afb43..d32efd0f 100644 --- a/src/lol/base/string.h +++ b/src/lol/base/string.h @@ -44,232 +44,3 @@ std::string vformat(char const *format, va_list ap); } /* namespace lol */ -// -// The deprecated String class -// --------------------------- -// A very simple String class, based on Array. The most interesting -// thing in there was LOL_ATTR_NODISCARD but apart from that there was -// no real point in using our own class. Phase this out. -// - -#include -#include - -#include -#include - -namespace lol -{ - -class LOL_ATTR_NODISCARD String : protected array -{ -private: - typedef array super; - -public: - inline String() - : super() - { - push('\0'); - } - - inline String(char const *str) - : super() - { - using namespace std; - ASSERT(str); - resize((int)strlen(str)); - memcpy(&(*this)[0], str, count() + 1); - } - - inline String(char const *str, int item_count) - : super() - { - using namespace std; - ASSERT(str); - resize(item_count); - memcpy(&(*this)[0], str, item_count); - ((super &)*this)[item_count] = '\0'; - } - - /* Legacy constructor for std::string */ - inline String(std::string const &s) - : String(s.c_str()) - { - } - - inline String(String const &s) - : super((super const &)s) - { - } - - inline char &operator [](int n) - { - /* Allow n == count() because we might have reasonable reasons - * to access that hidden null character. We cast to unsigned so - * as to avoid a harmless message from the GCC optimiser. */ - ASSERT(n >= 0); - ASSERT((unsigned)n <= (unsigned)count()); - return ((super &)*this)[n]; - } - - inline char const &operator [](int n) const - { - ASSERT(n >= 0); - ASSERT((unsigned)n <= (unsigned)count()); - return ((super const &)*this)[n]; - } - - inline char &last() - { - ASSERT(count() > 0); - return (*this)[count() - 1]; - } - - inline char const &last() const - { - ASSERT(count() > 0); - return (*this)[count() - 1]; - } - - inline int count() const - { - return ((super const &)*this).count() - 1; - } - - /* Return a C string */ - inline char const *C() const - { - return &(*this)[0]; - } - - /* Non-const version; make sure to not overflow the internal array */ - inline char *C() - { - return &(*this)[0]; - } - - /* Does not initialise the newly allocated characters */ - void resize(int item_count) - { - ASSERT(item_count >= 0); - ((super &)*this).resize(item_count + 1); - ((super &)*this).last() = '\0'; - } - - String sub(int start, int item_count = -1) const - { - ASSERT(start >= 0); - if (start >= count()) - return String(); - if (item_count < 0 || item_count >= count() - start) - item_count = count() - start; - return String(&(*this)[start], item_count); - } - - int replace(char const old_token, char const new_token, - bool all_occurrences = false) - { - using namespace std; - - int res = 0; - char *tmp = NULL; - while ((tmp = strrchr(C(), old_token))) - { - *tmp = new_token; - res++; - if (!all_occurrences) - break; - } - return res; - } - - inline String operator +(String const &s) const - { - String ret(*this); - return ret += s; - } - - inline String operator +(char c) const - { - String ret(*this); - return ret += c; - } - - inline String& operator +=(String const &s) - { - using namespace std; - int old_count = count(); - resize(count() + s.count()); - memcpy(&(*this)[old_count], &s[0], count() - old_count); - return *this; - } - - inline String& operator +=(char c) - { - ((super &)*this).last() = c; - ((super &)*this).push('\0'); - return *this; - } - - inline bool operator ==(String const &s) const - { - using namespace std; - return count() == s.count() - && memcmp(C(), s.C(), count()) == 0; - } - - inline bool operator !=(String const &s) const - { - return !(*this == s); - } - - inline bool operator ==(char const* sz) const - { - /* We parse the C string twice because of strlen + memcmp - * but it's probably still faster than doing it by hand. */ - using namespace std; - int sz_len = (int)strlen(sz); - return count() == sz_len - && memcmp(C(), sz, sz_len) == 0; - } - - inline bool operator !=(char const* sz) const - { - return !(*this == sz); - } - - inline bool operator <(String const & s) const - { - using namespace std; - int res = memcmp(C(), s.C(), count() < s.count() ? count() : s.count()); - - if (!res) - return count() < s.count(); - - return res < 0; - } -}; - -inline String operator +(char c, String const &s) -{ - return String() + c + s; -} - -inline String operator +(char const *sz, String const &s) -{ - return String(sz) + s; -} - -inline bool operator ==(char const* sz, String const &s) -{ - return s == sz; -} - -inline bool operator !=(char const* sz, String const &s) -{ - return s != sz; -} - -} /* namespace lol */ - diff --git a/src/lol/gpu/vertexbuffer.h b/src/lol/gpu/vertexbuffer.h index cde2e077..16cab021 100644 --- a/src/lol/gpu/vertexbuffer.h +++ b/src/lol/gpu/vertexbuffer.h @@ -54,7 +54,7 @@ struct MeshPrimitiveBase : public StructSafeEnum Lines, }; protected: - virtual bool BuildEnumMap(std::map& enum_map) + virtual bool BuildEnumMap(std::map& enum_map) { enum_map[Triangles] = "Triangles"; enum_map[TriangleStrips] = "TriangleStrips"; diff --git a/src/lol/image/color.h b/src/lol/image/color.h index d378267d..f715c63d 100644 --- a/src/lol/image/color.h +++ b/src/lol/image/color.h @@ -1,7 +1,7 @@ // // Lol Engine // -// Copyright © 2010—2015 Sam Hocevar +// Copyright © 2010—2018 Sam Hocevar // // Lol Engine is free software. It comes without any warranty, to // the extent permitted by applicable law. You can redistribute it @@ -345,7 +345,7 @@ public: /* * Convert hex strings to colors. */ - static vec4 C8BppHexString(String c); + static vec4 C8BppHexString(std::string const &c); /* * Some predefined colours diff --git a/src/lol/math/geometry.h b/src/lol/math/geometry.h index 99b72ff9..7b37ce63 100644 --- a/src/lol/math/geometry.h +++ b/src/lol/math/geometry.h @@ -37,7 +37,7 @@ struct AxisBase : public StructSafeEnum X = 0, Y, Z, MAX, XY = 2, XYZ = 3, }; protected: - virtual bool BuildEnumMap(std::map& enum_map) + virtual bool BuildEnumMap(std::map& enum_map) { enum_map[X] = "X"; enum_map[Y] = "Y"; @@ -58,7 +58,7 @@ struct DirectionBase : public StructSafeEnum Up = 0, Down, Left, Right, MAX, }; protected: - virtual bool BuildEnumMap(std::map& enum_map) + virtual bool BuildEnumMap(std::map& enum_map) { enum_map[Up] = "Up"; enum_map[Down] = "Down"; @@ -260,7 +260,7 @@ struct RayIntersectBase : public StructSafeEnum }; //LOL_DECLARE_ENUM_METHODS(RayIntersectBase) protected: - virtual bool BuildEnumMap(std::map& enum_map) + virtual bool BuildEnumMap(std::map& enum_map) { enum_map[Nothing] = "Nothing"; enum_map[All] = "All"; @@ -325,7 +325,7 @@ struct PlaneIntersectionBase : public StructSafeEnum Back, Front, Plane, }; protected: - virtual bool BuildEnumMap(std::map& enum_map) + virtual bool BuildEnumMap(std::map& enum_map) { enum_map[Back] = "Back"; enum_map[Front] = "Front"; diff --git a/src/lol/sys/threadtypes.h b/src/lol/sys/threadtypes.h index bb213d01..427d174a 100644 --- a/src/lol/sys/threadtypes.h +++ b/src/lol/sys/threadtypes.h @@ -80,7 +80,7 @@ class ThreadJob protected: inline ThreadJob(ThreadJobType type) : m_type(type) {} public: - char const *GetName() { return ""; } + std::string GetName() const { return ""; } inline ThreadJob() : m_type(ThreadJobType::NONE) {} virtual ~ThreadJob() {} diff --git a/src/lolimgui.h b/src/lolimgui.h index e306511d..eb528f96 100644 --- a/src/lolimgui.h +++ b/src/lolimgui.h @@ -176,7 +176,7 @@ public: //------------------------------------------------------------------------- LolImGui(); ~LolImGui(); - char const *GetName() { return ""; } + std::string GetName() const { return ""; } //------------------------------------------------------------------------- static void Init(); diff --git a/src/mesh/mesh.cpp b/src/mesh/mesh.cpp index 95c994f3..fb7746e9 100644 --- a/src/mesh/mesh.cpp +++ b/src/mesh/mesh.cpp @@ -1,7 +1,7 @@ // // Lol Engine // -// Copyright © 2010—2015 Sam Hocevar +// Copyright © 2010—2018 Sam Hocevar // // Lol Engine is free software. It comes without any warranty, to // the extent permitted by applicable law. You can redistribute it @@ -104,9 +104,9 @@ void SubMesh::SetIndexBuffer(IndexBuffer* ibo) m_ibo = ibo; } -void SubMesh::AddTexture(const char* name, Texture* texture) +void SubMesh::AddTexture(std::string const &name, Texture* texture) { - m_textures.push(String(name), texture); + m_textures.push(name, texture); } void SubMesh::Render() @@ -142,7 +142,7 @@ void SubMesh::Render() for (int i = 0; i < m_textures.count(); ++i) { // TODO: might be good to cache this - ShaderUniform u_tex = m_shader->GetUniformLocation(m_textures[i].m1.C()); + ShaderUniform u_tex = m_shader->GetUniformLocation(m_textures[i].m1); m_shader->SetUniform(u_tex, m_textures[i].m2->GetTextureUniform(), i); } diff --git a/src/mesh/mesh.h b/src/mesh/mesh.h index bce6f12e..7035db39 100644 --- a/src/mesh/mesh.h +++ b/src/mesh/mesh.h @@ -1,7 +1,7 @@ // // Lol Engine // -// Copyright © 2010—2016 Sam Hocevar +// Copyright © 2010—2018 Sam Hocevar // // Lol Engine is free software. It comes without any warranty, to // the extent permitted by applicable law. You can redistribute it @@ -94,7 +94,7 @@ public: void SetVertexDeclaration(VertexDeclaration *vdecl); void SetVertexBuffer(int index, VertexBuffer* vbo); void SetIndexBuffer(IndexBuffer* ibo); - void AddTexture(const char* name, Texture* texture); + void AddTexture(std::string const &name, Texture* texture); protected: void Render(); @@ -105,7 +105,7 @@ protected: array m_vbos; IndexBuffer *m_ibo; - array m_textures; + array m_textures; }; } /* namespace lol */ diff --git a/src/messageservice.h b/src/messageservice.h index fde0e567..dae9bfb0 100644 --- a/src/messageservice.h +++ b/src/messageservice.h @@ -89,7 +89,7 @@ public: MessageService(); ~MessageService(); - static char const *GetName() { return ""; } + static std::string GetName() { return ""; } //Setup/Destroy static void Setup(); diff --git a/src/sys/getopt.cpp b/src/sys/getopt.cpp index d2a79684..96221ea0 100644 --- a/src/sys/getopt.cpp +++ b/src/sys/getopt.cpp @@ -1,7 +1,7 @@ // // Lol Engine // -// Copyright © 2002—2016 Sam Hocevar +// Copyright © 2002—2018 Sam Hocevar // // Lol Engine is free software. It comes without any warranty, to // the extent permitted by applicable law. You can redistribute it @@ -44,7 +44,7 @@ struct getopt_private int m_argc; char * const *m_argv; - String m_optstring; + std::string m_optstring; array m_opts; }; @@ -90,7 +90,7 @@ int getopt::parse() optind = this->index; optarg = this->arg; m_private->m_opts.push(getopt_private::optdesc { nullptr, 0, nullptr, 0 }); - ret = getopt_long(m_private->m_argc, m_private->m_argv, m_private->m_optstring.C(), + ret = getopt_long(m_private->m_argc, m_private->m_argv, m_private->m_optstring.c_str(), (option const *)m_private->m_opts.data(), &longindex); this->index = optind; this->arg = optarg; @@ -117,7 +117,7 @@ int getopt::parse() if (ret == '\0') return -1; - tmp = strchr(m_private->m_optstring.C(), ret); + tmp = strchr(m_private->m_optstring.c_str(), ret); if (!tmp || ret == ':') return '?'; diff --git a/src/sys/threadtypes.cpp b/src/sys/threadtypes.cpp index 446b6860..f6eb3986 100644 --- a/src/sys/threadtypes.cpp +++ b/src/sys/threadtypes.cpp @@ -32,14 +32,19 @@ class FileUpdateTesterJob : public ThreadJob { friend class FileUpdateTester; public: - char const *GetName() { return ""; } + std::string GetName() const { return ""; } + FileUpdateTesterJob() - : ThreadJob(ThreadJobType::NONE) { } + : ThreadJob(ThreadJobType::NONE) + { + } + FileUpdateTesterJob(std::string const &path) - : ThreadJob(ThreadJobType::WORK_TODO) + : ThreadJob(ThreadJobType::WORK_TODO), + m_path(path) { - m_path = path; } + std::string const &GetPath() { return m_path; } long int GetTime() { return m_time; } bool HasUpdated() { return m_updated; } @@ -156,7 +161,8 @@ void FileUpdateTester::TreatResult(ThreadJob* result) class AsyncImageJob : public ThreadJob { public: - char const *GetName() { return ""; } + std::string GetName() const { return ""; } + AsyncImageJob() : ThreadJob(ThreadJobType::NONE) { diff --git a/src/t/base/array.cpp b/src/t/base/array.cpp index af3653da..5cbbf554 100644 --- a/src/t/base/array.cpp +++ b/src/t/base/array.cpp @@ -1,7 +1,7 @@ // // Lol Engine — Unit tests // -// Copyright © 2010—2015 Sam Hocevar +// Copyright © 2010—2018 Sam Hocevar // // Lol Engine is free software. It comes without any warranty, to // the extent permitted by applicable law. You can redistribute it @@ -191,7 +191,7 @@ lolunit_declare_fixture(array_test) lolunit_declare_test(array_insert_tuple) { - array b; + array b; b.insert(0, 5, 6.f, "lol"); lolunit_assert_equal(5, b[0].m1); lolunit_assert_equal(6.f, b[0].m2); diff --git a/src/t/sys/thread.cpp b/src/t/sys/thread.cpp index c154e52f..f240bb8f 100644 --- a/src/t/sys/thread.cpp +++ b/src/t/sys/thread.cpp @@ -28,9 +28,12 @@ lolunit_declare_fixture(thread_test) { friend class UnitTestThreadManager; public: - char const *GetName() { return ""; } - UnitTestJob() : ThreadJob(ThreadJobType::WORK_TODO) + std::string GetName() const { return ""; } + + UnitTestJob() + : ThreadJob(ThreadJobType::WORK_TODO) { } + bool IsDone() { return m_done; @@ -41,9 +44,9 @@ lolunit_declare_fixture(thread_test) { timer t; m_done = false; - msg::info("%s: STARTED WORK\n", GetName()); + msg::info("%s: STARTED WORK\n", GetName().c_str()); t.wait(2.f); - msg::info("%s: ENDED WORK\n", GetName()); + msg::info("%s: ENDED WORK\n", GetName().c_str()); m_done = true; return true; } @@ -76,7 +79,7 @@ lolunit_declare_fixture(thread_test) typedef SafeEnum UnitTestStatus; public: - char const *GetName() { return ""; } + std::string GetName() const { return ""; } UnitTestThreadManager() : BaseThreadManager(4, 1) { } virtual ~UnitTestThreadManager() @@ -84,14 +87,14 @@ lolunit_declare_fixture(thread_test) void AddJob(ThreadJob* job) { - msg::info("%s DISPATCHING JOB %s\n", GetName(), job->GetName()); + msg::info("%s DISPATCHING JOB %s\n", GetName().c_str(), job->GetName().c_str()); DispatchJob(job); } bool GetWorkResult(array& results) { results += m_job_result; m_job_result.empty(); - msg::info("%s GETWORKRESULT (%i)\n", GetName(), results.count()); + msg::info("%s GETWORKRESULT (%i)\n", GetName().c_str(), results.count()); return results.count() > 0; } @@ -102,7 +105,7 @@ lolunit_declare_fixture(thread_test) case UnitTestStatus::NOT_QUEUED: if (!!GetDispatchCount()) { - msg::info("%s TICKGAME %s\n", GetName(), m_status.tostring().c_str()); + msg::info("%s TICKGAME %s\n", GetName().c_str(), m_status.tostring().c_str()); m_status = UnitTestStatus::QUEUED; } break; @@ -113,14 +116,14 @@ lolunit_declare_fixture(thread_test) if (GetDispatchedCount()) #endif { - msg::info("%s TICKGAME %s\n", GetName(), m_status.tostring().c_str()); + msg::info("%s TICKGAME %s\n", GetName().c_str(), m_status.tostring().c_str()); m_status = UnitTestStatus::RETRIEVED; } break; case UnitTestStatus::RETRIEVED: if (m_job_result.count() == 4) { - msg::info("%s TICKGAME %s\n", GetName(), m_status.tostring().c_str()); + msg::info("%s TICKGAME %s\n", GetName().c_str(), m_status.tostring().c_str()); m_status = UnitTestStatus::DONE; } break; @@ -154,10 +157,10 @@ lolunit_declare_fixture(thread_test) lolunit_declare_test(threads) { - msg::info("%s START\n", m_manager.GetName()); + msg::info("%s START\n", m_manager.GetName().c_str()); //Start threads manager m_manager.Start(); - msg::info("%s STARTED\n", m_manager.GetName()); + msg::info("%s STARTED\n", m_manager.GetName().c_str()); UnitTestJob job[4]; lolunit_assert_equal(0, m_manager.Test_GetDispatchCount()); @@ -190,10 +193,10 @@ lolunit_declare_fixture(thread_test) m_manager.GetWorkResult(results); lolunit_assert_equal(4, results.count()); - msg::info("%s STOP\n", m_manager.GetName()); + msg::info("%s STOP\n", m_manager.GetName().c_str()); //Stop manager m_manager.Stop(); - msg::info("%s STOPPED\n", m_manager.GetName()); + msg::info("%s STOPPED\n", m_manager.GetName().c_str()); } lolunit_declare_test(queue_try_push) diff --git a/src/text.cpp b/src/text.cpp index 23375256..c2f2472c 100644 --- a/src/text.cpp +++ b/src/text.cpp @@ -1,7 +1,7 @@ // // Lol Engine // -// Copyright © 2010—2015 Sam Hocevar +// Copyright © 2010—2018 Sam Hocevar // // Lol Engine is free software. It comes without any warranty, to // the extent permitted by applicable law. You can redistribute it @@ -30,7 +30,7 @@ class TextData private: int m_font; TextAlign m_align; - String m_text; + std::string m_text; vec3 m_pos; vec2 m_scale; float m_spacing; @@ -40,7 +40,7 @@ private: * Public Text class */ -Text::Text(String const &text, char const *font) +Text::Text(std::string const &text, char const *font) : data(new TextData()) { data->m_font = Forge::Register(font); @@ -53,7 +53,7 @@ Text::Text(String const &text, char const *font) m_drawgroup = DRAWGROUP_HUD; } -void Text::SetText(String const &text) +void Text::SetText(std::string const &text) { data->m_text = text; } @@ -98,7 +98,7 @@ void Text::TickDraw(float seconds, Scene &scene) { Entity::TickDraw(seconds, scene); - if (auto length = data->m_text.count()) + if (auto length = data->m_text.length()) { Font *font = Forge::GetFont(data->m_font); vec3 delta(0.0f); @@ -110,7 +110,7 @@ void Text::TickDraw(float seconds, Scene &scene) else if (data->m_align == TextAlign::Center) delta.x -= 0.5f * text_width * data->m_scale.x; - font->Print(scene, data->m_pos + delta, data->m_text.C(), + font->Print(scene, data->m_pos + delta, data->m_text, data->m_scale, data->m_spacing); } } diff --git a/src/text.h b/src/text.h index 52339e79..583aec7e 100644 --- a/src/text.h +++ b/src/text.h @@ -1,11 +1,13 @@ // -// Lol Engine +// Lol Engine // -// Copyright: (c) 2010-2013 Sam Hocevar -// This program is free software; you can redistribute it and/or -// modify it under the terms of the Do What The Fuck You Want To -// Public License, Version 2, as published by Sam Hocevar. See -// http://www.wtfpl.net/ for more details. +// Copyright © 2010—2018 Sam Hocevar +// +// Lol Engine is free software. It comes without any warranty, to +// the extent permitted by applicable law. You can redistribute it +// and/or modify it under the terms of the Do What the Fuck You Want +// to Public License, Version 2, as published by the WTFPL Task Force. +// See http://www.wtfpl.net/ for more details. // #pragma once @@ -17,6 +19,8 @@ #include "engine/entity.h" +#include + namespace lol { @@ -32,11 +36,11 @@ enum class TextAlign class Text : public Entity { public: - Text(String const &text, char const *font); + Text(std::string const &text, char const *font); virtual ~Text(); /** Set the text that will be displayed */ - void SetText(String const &text); + void SetText(std::string const &text); void SetInt(int val); /** Set the position of the text object, in the 3D world. */ diff --git a/src/textureimage-private.h b/src/textureimage-private.h index 42179a90..da1ef7a9 100644 --- a/src/textureimage-private.h +++ b/src/textureimage-private.h @@ -1,11 +1,13 @@ // -// Lol Engine +// Lol Engine // -// Copyright: (c) 2010-2013 Sam Hocevar -// This program is free software; you can redistribute it and/or -// modify it under the terms of the Do What The Fuck You Want To -// Public License, Version 2, as published by Sam Hocevar. See -// http://www.wtfpl.net/ for more details. +// Copyright © 2010—2018 Sam Hocevar +// +// Lol Engine is free software. It comes without any warranty, to +// the extent permitted by applicable law. You can redistribute it +// and/or modify it under the terms of the Do What the Fuck You Want +// to Public License, Version 2, as published by the WTFPL Task Force. +// See http://www.wtfpl.net/ for more details. // #pragma once @@ -27,7 +29,7 @@ class TextureImageData //T'was protected .... should it be ? public: - String m_name; + std::string m_name; /* Pixels, then texture coordinates */ ivec2 m_image_size, m_texture_size; diff --git a/src/textureimage.cpp b/src/textureimage.cpp index e87beeb0..50cc24a2 100644 --- a/src/textureimage.cpp +++ b/src/textureimage.cpp @@ -1,7 +1,7 @@ // // Lol Engine // -// Copyright © 2010—2017 Sam Hocevar +// Copyright © 2010—2018 Sam Hocevar // // Lol Engine is free software. It comes without any warranty, to // the extent permitted by applicable law. You can redistribute it @@ -40,13 +40,13 @@ TextureImageData* TextureImage::GetNewData() * Public TextureImage class */ -TextureImage::TextureImage(char const *path) +TextureImage::TextureImage(std::string const &path) : m_data(GetNewData()) { Init(path); } -TextureImage::TextureImage(char const *path, image* img) +TextureImage::TextureImage(std::string const &path, image* img) : m_data(GetNewData()) { Init(path, img); @@ -57,12 +57,12 @@ TextureImage::~TextureImage() delete m_data; } -void TextureImage::Init(char const *path) +void TextureImage::Init(std::string const &path) { Init(path, ResourceLoader::Load(path)); } -void TextureImage::Init(char const *path, ResourceCodecData* loaded_data) +void TextureImage::Init(std::string const &path, ResourceCodecData* loaded_data) { //Load image if available auto image_data = dynamic_cast(loaded_data); @@ -74,9 +74,9 @@ void TextureImage::Init(char const *path, ResourceCodecData* loaded_data) delete image_data; } -void TextureImage::Init(char const *path, image* img) +void TextureImage::Init(std::string const &path, image* img) { - m_data->m_name = String(" ") + path; + m_data->m_name = " " + path; m_data->m_texture = nullptr; m_data->m_image = img; @@ -144,9 +144,9 @@ void TextureImage::TickDraw(float seconds, Scene &scene) } //----------------------------------------------------------------------------- -char const *TextureImage::GetName() +std::string TextureImage::GetName() const { - return m_data->m_name.C(); + return m_data->m_name; } void TextureImage::UpdateTexture(image* img) diff --git a/src/textureimage.h b/src/textureimage.h index 2ef7500f..896490cb 100644 --- a/src/textureimage.h +++ b/src/textureimage.h @@ -1,11 +1,13 @@ // -// Lol Engine +// Lol Engine // -// Copyright: (c) 2010-2013 Sam Hocevar -// This program is free software; you can redistribute it and/or -// modify it under the terms of the Do What The Fuck You Want To -// Public License, Version 2, as published by Sam Hocevar. See -// http://www.wtfpl.net/ for more details. +// Copyright © 2010—2018 Sam Hocevar +// +// Lol Engine is free software. It comes without any warranty, to +// the extent permitted by applicable law. You can redistribute it +// and/or modify it under the terms of the Do What the Fuck You Want +// to Public License, Version 2, as published by the WTFPL Task Force. +// See http://www.wtfpl.net/ for more details. // #pragma once @@ -38,21 +40,21 @@ protected: virtual TextureImageData* GetNewData(); public: - TextureImage(char const *path); - TextureImage(char const *path, image* img); + TextureImage(std::string const &path); + TextureImage(std::string const &path, image* img); virtual ~TextureImage(); protected: - void Init(char const *path); - virtual void Init(char const *path, ResourceCodecData* loaded_data); - virtual void Init(char const *path, image* img); + void Init(std::string const &path); + virtual void Init(std::string const &path, ResourceCodecData* loaded_data); + virtual void Init(std::string const &path, image* img); protected: virtual void TickDraw(float seconds, Scene &scene); public: /* Inherited from Entity */ - virtual char const *GetName(); + virtual std::string GetName() const; void UpdateTexture(image* img); Texture * GetTexture(); diff --git a/src/tiler.cpp b/src/tiler.cpp index 3cd649cf..6bc7c1f9 100644 --- a/src/tiler.cpp +++ b/src/tiler.cpp @@ -1,11 +1,13 @@ // -// Lol Engine +// Lol Engine // -// Copyright: (c) 2010-2013 Sam Hocevar -// This program is free software; you can redistribute it and/or -// modify it under the terms of the Do What The Fuck You Want To -// Public License, Version 2, as published by Sam Hocevar. See -// http://www.wtfpl.net/ for more details. +// Copyright © 2010—2018 Sam Hocevar +// +// Lol Engine is free software. It comes without any warranty, to +// the extent permitted by applicable law. You can redistribute it +// and/or modify it under the terms of the Do What the Fuck You Want +// to Public License, Version 2, as published by the WTFPL Task Force. +// See http://www.wtfpl.net/ for more details. // #include @@ -36,11 +38,7 @@ static TilerData * const data = &tilerdata; * Public Tiler class */ -TileSet *Tiler::Register(String const &path, ivec2 size, ivec2 count) -{ - return Tiler::Register(path.C(), size, count); -} -TileSet *Tiler::Register(char const *path, ivec2 size, ivec2 count) +TileSet *Tiler::Register(std::string const &path, ivec2 size, ivec2 count) { int id = data->tilesets.MakeSlot(path); TileSet *tileset = (TileSet *)data->tilesets.GetEntity(id); @@ -54,11 +52,7 @@ TileSet *Tiler::Register(char const *path, ivec2 size, ivec2 count) return tileset; } -TileSet *Tiler::Register(String const &path) -{ - return Tiler::Register(path.C()); -} -TileSet *Tiler::Register(char const *path) +TileSet *Tiler::Register(std::string const &path) { int id = data->tilesets.MakeSlot(path); TileSet *tileset = (TileSet *)data->tilesets.GetEntity(id); @@ -72,11 +66,7 @@ TileSet *Tiler::Register(char const *path) return tileset; } -TileSet *Tiler::Register(String const &path, Image* image, ivec2 size, ivec2 count) -{ - return Tiler::Register(path.C(), image, size, count); -} -TileSet *Tiler::Register(char const *path, Image* image, ivec2 size, ivec2 count) +TileSet *Tiler::Register(std::string const &path, Image* image, ivec2 size, ivec2 count) { int id = data->tilesets.MakeSlot(path); TileSet *tileset = (TileSet *)data->tilesets.GetEntity(id); @@ -90,11 +80,7 @@ TileSet *Tiler::Register(char const *path, Image* image, ivec2 size, ivec2 count return tileset; } -TileSet *Tiler::Register(String const &path, Image* image) -{ - return Tiler::Register(path.C(), image); -} -TileSet *Tiler::Register(char const *path, Image* image) +TileSet *Tiler::Register(std::string const &path, Image* image) { int id = data->tilesets.MakeSlot(path); TileSet *tileset = (TileSet *)data->tilesets.GetEntity(id); diff --git a/src/tiler.h b/src/tiler.h index 7ec6f91b..69383e94 100644 --- a/src/tiler.h +++ b/src/tiler.h @@ -1,11 +1,13 @@ // -// Lol Engine +// Lol Engine // -// Copyright: (c) 2010-2013 Sam Hocevar -// This program is free software; you can redistribute it and/or -// modify it under the terms of the Do What The Fuck You Want To -// Public License, Version 2, as published by Sam Hocevar. See -// http://www.wtfpl.net/ for more details. +// Copyright © 2010—2018 Sam Hocevar +// +// Lol Engine is free software. It comes without any warranty, to +// the extent permitted by applicable law. You can redistribute it +// and/or modify it under the terms of the Do What the Fuck You Want +// to Public License, Version 2, as published by the WTFPL Task Force. +// See http://www.wtfpl.net/ for more details. // #pragma once @@ -26,14 +28,10 @@ namespace lol class Tiler { public: - static TileSet *Register(String const &path, ivec2 size, ivec2 count); - static TileSet *Register(char const *path, ivec2 size, ivec2 count); - static TileSet *Register(String const &path); - static TileSet *Register(char const *path); - static TileSet *Register(String const &path, image* img, ivec2 size, ivec2 count); - static TileSet *Register(char const *path, image* img, ivec2 size, ivec2 count); - static TileSet *Register(String const &path, image* img); - static TileSet *Register(char const *path, image* img); + static TileSet *Register(std::string const &path, ivec2 size, ivec2 count); + static TileSet *Register(std::string const &path); + static TileSet *Register(std::string const &path, image* img, ivec2 size, ivec2 count); + static TileSet *Register(std::string const &path, image* img); static void Deregister(TileSet *); private: diff --git a/src/tileset.cpp b/src/tileset.cpp index eac4f1e9..831c9a5d 100644 --- a/src/tileset.cpp +++ b/src/tileset.cpp @@ -1,7 +1,7 @@ // // Lol Engine // -// Copyright © 2010—2015 Sam Hocevar +// Copyright © 2010—2018 Sam Hocevar // // Lol Engine is free software. It comes without any warranty, to // the extent permitted by applicable law. You can redistribute it @@ -45,21 +45,21 @@ protected: * Public TileSet class */ -TileSet::TileSet(char const *path) +TileSet::TileSet(std::string const &path) : TextureImage(path), m_tileset_data(new TileSetData()), m_palette(nullptr) { } -TileSet::TileSet(char const *path, Image* image) +TileSet::TileSet(std::string const &path, Image* image) : TextureImage(path, image), m_tileset_data(new TileSetData()), m_palette(nullptr) { } -TileSet::TileSet(char const *path, Image* image, array& tiles) +TileSet::TileSet(std::string const &path, Image* image, array& tiles) : TextureImage(path, image), m_tileset_data(new TileSetData()), m_palette(nullptr) @@ -67,7 +67,7 @@ TileSet::TileSet(char const *path, Image* image, array& tiles) define_tile(tiles); } -TileSet::TileSet(char const *path, ivec2 size, ivec2 count) +TileSet::TileSet(std::string const &path, ivec2 size, ivec2 count) : TileSet(path) { /* If count is valid, fix size; otherwise, fix count. */ @@ -90,7 +90,7 @@ TileSet::TileSet(char const *path, ivec2 size, ivec2 count) } } -TileSet::TileSet(char const *path, Image* image, ivec2 size, ivec2 count) +TileSet::TileSet(std::string const &path, Image* image, ivec2 size, ivec2 count) : TileSet(path, image) { /* If count is valid, fix size; otherwise, fix count. */ @@ -118,7 +118,7 @@ TileSet::~TileSet() delete m_tileset_data; } -void TileSet::Init(char const *path, ResourceCodecData* loaded_data) +void TileSet::Init(std::string const &path, ResourceCodecData* loaded_data) { //Load tileset if available auto tileset_data = dynamic_cast(loaded_data); @@ -127,22 +127,22 @@ void TileSet::Init(char const *path, ResourceCodecData* loaded_data) define_tile(tileset_data->m_tiles); } - m_data->m_name = String(" ") + path; + m_data->m_name = " " + path; super::Init(path, loaded_data); } -void TileSet::Init(char const *path, Image* image) +void TileSet::Init(std::string const &path, Image* image) { super::Init(path, image); - m_data->m_name = String(" ") + path; + m_data->m_name = " " + path; } //Inherited from Entity ------------------------------------------------------- -char const *TileSet::GetName() +std::string TileSet::GetName() const { - return m_data->m_name.C(); + return m_data->m_name; } //New methods ----------------------------------------------------------------- diff --git a/src/tileset.h b/src/tileset.h index cea01d10..ca91ef1b 100644 --- a/src/tileset.h +++ b/src/tileset.h @@ -1,7 +1,7 @@ // // Lol Engine // -// Copyright © 2010—2015 Sam Hocevar +// Copyright © 2010—2018 Sam Hocevar // // Lol Engine is free software. It comes without any warranty, to // the extent permitted by applicable law. You can redistribute it @@ -41,23 +41,23 @@ class TileSet : public TextureImage typedef TextureImage super; public: - TileSet(char const *path); - TileSet(char const *path, image* img); - TileSet(char const *path, image* img, array& tiles); + TileSet(std::string const &path); + TileSet(std::string const &path, image* img); + TileSet(std::string const &path, image* img, array& tiles); /* Old style: path to PNG file */ - TileSet(char const *path, ivec2 size, ivec2 count); - TileSet(char const *path, image* img, ivec2 size, ivec2 count); + TileSet(std::string const &path, ivec2 size, ivec2 count); + TileSet(std::string const &path, image* img, ivec2 size, ivec2 count); virtual ~TileSet(); protected: - virtual void Init(char const *path, ResourceCodecData* loaded_data); - virtual void Init(char const *path, image* img); + virtual void Init(std::string const &path, ResourceCodecData* loaded_data); + virtual void Init(std::string const &path, image* img); public: /* Inherited from Entity */ - virtual char const *GetName(); + virtual std::string GetName() const; /* New methods */ void clear_all();