Skip to content

Commit

Permalink
Update entities and file system
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelheilmann committed Nov 11, 2017
1 parent 2cca430 commit 02b20f6
Show file tree
Hide file tree
Showing 41 changed files with 293 additions and 887 deletions.
10 changes: 4 additions & 6 deletions cartman/src/cartman/cartman.c
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ bool load_module( const std::string& modname, cartman_mpd_t * pmesh )

std::string mod_path = std::string("/modules/") + modname;

if (!setup_init_module_vfs_paths(modname.c_str()))
if (!setup_init_module_vfs_paths(modname))
{
return false;
}
Expand Down Expand Up @@ -1898,19 +1898,17 @@ void cartman_create_mesh( cartman_mpd_t * pmesh )

void cartman_save_mesh( const char * modname, cartman_mpd_t * pmesh )
{
STRING newloadname;

if ( NULL == pmesh ) pmesh = &mesh;

numwritten = 0;
numattempt = 0;

sprintf( newloadname, "%s" SLASH_STR "modules" SLASH_STR "%s" SLASH_STR "gamedat" SLASH_STR "plan.bmp", egoboo_path.c_str(), modname );

std::string newloadname = egoboo_path + SLASH_STR + "modules" + SLASH_STR + modname + SLASH_STR + "gamedat" + SLASH_STR + "plan.bmp";
make_planmap( pmesh );
if (Resources::get().bmphitemap )
{
SDL_SaveBMP_RW(Resources::get().bmphitemap.get(), vfs_openRWopsWrite(newloadname), 1 );
SDL_SaveBMP_RW(Resources::get().bmphitemap.get(), vfs_openRWopsWrite(newloadname.c_str()), 1 );
}

// make_newloadname(modname, SLASH_STR "gamedat" SLASH_STR "level.png", newloadname);
Expand Down
4 changes: 2 additions & 2 deletions egolib/src/egolib/Configuration/Number.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ class Variable<ValueType, std::enable_if_t<!std::is_same<ValueType, bool>::value

virtual bool encodeValue(std::string& target) const override
{
return Script::Encoder<ValueType>()(this->getValue(), target);
return id::c::encoder<ValueType>()(this->getValue(), target);
}

virtual bool decodeValue(const std::string& source) override
{
ValueType temporary = {};
if (!Script::Decoder<ValueType>()(source, temporary))
if (!id::c::decoder<ValueType>()(source, temporary))
{
return false;
}
Expand Down
4 changes: 2 additions & 2 deletions egolib/src/egolib/Configuration/StringOrBool.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ class Variable<ValueType, std::enable_if_t<id::is_any_of<ValueType, std::string,

virtual bool encodeValue(std::string& target) const override
{
return Script::Encoder<ValueType>()(this->getValue(), target);
return id::c::encoder<ValueType>()(this->getValue(), target);
}

virtual bool decodeValue(const std::string& source) override
{
ValueType temporary;
if (!Script::Decoder<ValueType>()(source, temporary))
if (!id::c::decoder<ValueType>()(source, temporary))
{
return false;
}
Expand Down
1 change: 0 additions & 1 deletion egolib/src/egolib/Configuration/Variable.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#pragma once

#include "egolib/Script/EnumDescriptor.hpp"
#include "egolib/Script/Conversion.hpp"

namespace Ego {
namespace Configuration {
Expand Down
16 changes: 8 additions & 8 deletions egolib/src/egolib/Entities/Object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ constexpr float Object::DROPZVEL;
constexpr float Object::DISMOUNTZVEL;

Object::Object(ObjectProfileRef proRef, ObjectRef objRef) :
spawn_data(),
ai(),
gender(Gender::Male),
experience(0),
Expand Down Expand Up @@ -110,6 +109,7 @@ Object::Object(ObjectProfileRef proRef, ObjectRef objRef) :
shadow_size_save(0),
is_overlay(false),
skin(0),
skin_stt(0),
basemodel_ref(proRef),

bump_stt(),
Expand Down Expand Up @@ -752,7 +752,7 @@ void Object::update()
if (!inwater)
{
// Splash
ParticleHandler::get().spawnGlobalParticle({getPosX(), getPosY(), _currentModule->getWater().get_level() + 10}, Facing::ATK_FRONT, LocalParticleProfileRef(PIP_SPLASH), 0);
ParticleHandler::get().spawnGlobalParticle({getPosX(), getPosY(), _currentModule->getWater().get_level() + 10}, ATK_FRONT, LocalParticleProfileRef(PIP_SPLASH), 0);

if ( _currentModule->getWater()._is_water )
{
Expand Down Expand Up @@ -790,7 +790,7 @@ void Object::update()

if ( 0 == ( (update_wld + getObjRef().get()) & ripand ))
{
ParticleHandler::get().spawnGlobalParticle({getPosX(), getPosY(), _currentModule->getWater().get_level()}, Facing::ATK_FRONT, LocalParticleProfileRef(PIP_RIPPLE), 0);
ParticleHandler::get().spawnGlobalParticle({getPosX(), getPosY(), _currentModule->getWater().get_level()}, ATK_FRONT, LocalParticleProfileRef(PIP_RIPPLE), 0);
}
}
}
Expand Down Expand Up @@ -1201,7 +1201,7 @@ bool Object::detatchFromHolder(const bool ignoreKurse, const bool doShop)
//Throw us forward if we can collide with the holder (for example the Stool)
//This prevents us from being dropped into the collision box of the holder
if(bump.size > 0) {
Ego::Math::Radians angle = FacingToRadian(Facing(ori.facing_z) + Facing::ATK_BEHIND);
Ego::Math::Radians angle = FacingToRadian(Facing(ori.facing_z) + ATK_BEHIND);
setVelocity(getVelocity() + Vector3f(std::cos(angle) * DROPXYVEL * 0.5f,
std::sin(angle) * DROPXYVEL * 0.5f,
0.0f));
Expand Down Expand Up @@ -2827,7 +2827,7 @@ void Object::dropMoney(int amount)

for (size_t i = 0; i < count; i++)
{
ParticleHandler::get().spawnGlobalParticle(pos, Facing::ATK_FRONT, LocalParticleProfileRef(pips[cnt]), i);
ParticleHandler::get().spawnGlobalParticle(pos, ATK_FRONT, LocalParticleProfileRef(pips[cnt]), i);
}
}
}
Expand Down Expand Up @@ -2866,7 +2866,7 @@ void Object::dropKeys()
// fix some flags
pkey->hitready = true;
pkey->isequipped = false;
pkey->ori.facing_z = Facing(FACING_T(direction + Facing::ATK_BEHIND));
pkey->ori.facing_z = Facing(FACING_T(direction + ATK_BEHIND));
pkey->team = pkey->team_base;

// fix the current velocity
Expand Down Expand Up @@ -2905,7 +2905,7 @@ void Object::dropAllItems()
const FACING_T diradd = (std::numeric_limits<FACING_T>::max()/2) / pack_count;

// now drop each item in turn
Facing direction = ori.facing_z + Facing::ATK_BEHIND - Facing(diradd * (pack_count/2));
Facing direction = ori.facing_z + ATK_BEHIND - Facing(diradd * (pack_count/2));
for(const std::shared_ptr<Object> &pitem : getInventory().iterate())
{
//remove it from inventory
Expand All @@ -2922,7 +2922,7 @@ void Object::dropAllItems()

// fix some flags
pitem->hitready = true;
pitem->ori.facing_z = Facing(FACING_T(Facing(direction) + Facing::ATK_BEHIND));
pitem->ori.facing_z = Facing(FACING_T(Facing(direction) + ATK_BEHIND));
pitem->team = pitem->team_base;

// fix the current velocity
Expand Down
27 changes: 1 addition & 26 deletions egolib/src/egolib/Entities/Object.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,30 +54,6 @@ enum turn_mode_t : uint8_t
TURNMODE_COUNT
};

/// the data used to define the spawning of a character
struct chr_spawn_data_t
{
chr_spawn_data_t() :
pos(),
profile(),
team(0),
skin(0),
facing(0),
name(),
override()
{
//ctor
}

Vector3f pos;
ObjectProfileRef profile;
TEAM_REF team;
int skin;
Facing facing;
STRING name;
ObjectRef override;
};

//--------------------------------------------------------------------------------------------

/// The offsets of Bits identifying in-game actions in a Bit set.
Expand Down Expand Up @@ -848,8 +824,6 @@ class Object : public PhysicsData, private id::non_copyable, public Ego::Physics
void updateLatchButtons();

public:
chr_spawn_data_t spawn_data;

// character state
ai_state_t ai; ///< ai data

Expand Down Expand Up @@ -928,6 +902,7 @@ class Object : public PhysicsData, private id::non_copyable, public Ego::Physics
// model info
bool is_overlay; ///< Is this an overlay? Track aitarget...
SKIN_T skin; ///< Character's skin
SKIN_T skin_stt; ///< Character's initial skin
ObjectProfileRef basemodel_ref; ///< The true form

// collision info
Expand Down
4 changes: 2 additions & 2 deletions egolib/src/egolib/FileFormats/ConfigFile/ConfigFileToken.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
ConfigFileToken::ConfigFileToken
(
ConfigFileTokenKind kind,
const id::location& startLocation,
const id::c::location& startLocation,
const std::string& lexeme
) :
id::token<ConfigFileTokenKind, ConfigFileTokenKind::Unknown>(kind, startLocation, lexeme)
id::c::token<ConfigFileTokenKind, ConfigFileTokenKind::Unknown>(kind, startLocation, lexeme)
{}
4 changes: 2 additions & 2 deletions egolib/src/egolib/FileFormats/ConfigFile/ConfigFileToken.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

#include "egolib/FileFormats/ConfigFile/ConfigFileTokenKind.hpp"

class ConfigFileToken : public id::token<ConfigFileTokenKind, ConfigFileTokenKind::Unknown>
class ConfigFileToken : public id::c::token<ConfigFileTokenKind, ConfigFileTokenKind::Unknown>
{
public:
ConfigFileToken
(
ConfigFileTokenKind kind,
const id::location& startLocation,
const id::c::location& startLocation,
const std::string& lexeme = std::string()
);
};
8 changes: 4 additions & 4 deletions egolib/src/egolib/FileFormats/ConfigFile/configfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,14 @@ const std::string& ConfigCommentLine::getText() const

//--------------------------------------------------------------------------------------------

ConfigEntry::ConfigEntry(const id::qualified_name& qualifiedName, const std::string& value) :
ConfigEntry::ConfigEntry(const id::c::qualified_name& qualifiedName, const std::string& value) :
m_qualifiedName(qualifiedName), m_value(value), m_commentLines()
{}

ConfigEntry::~ConfigEntry()
{}

const id::qualified_name& ConfigEntry::getQualifiedName() const
const id::c::qualified_name& ConfigEntry::getQualifiedName() const
{
return m_qualifiedName;
}
Expand Down Expand Up @@ -232,7 +232,7 @@ bool ConfigFileParser::parseQualifiedName()
return false;
}
}
_currentQualifiedName.reset(new id::qualified_name(get_lexeme_text()));
_currentQualifiedName.reset(new id::c::qualified_name(get_lexeme_text()));

return true;
}
Expand Down Expand Up @@ -318,7 +318,7 @@ bool ConfigFileUnParser::unparse(std::shared_ptr<ConfigFile> source)
std::sort(entries.begin(), entries.end(),
[] (const std::shared_ptr<ConfigEntry>& a, const std::shared_ptr<ConfigEntry>& b)
{
return std::less<id::qualified_name>()(a->getQualifiedName(), b->getQualifiedName());
return std::less<id::c::qualified_name>()(a->getQualifiedName(), b->getQualifiedName());
}
);
for (const auto& entry : entries)
Expand Down
16 changes: 8 additions & 8 deletions egolib/src/egolib/FileFormats/ConfigFile/configfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ struct ConfigEntry
std::vector<ConfigCommentLine> m_commentLines;

/// @brief The qualified name of this entry.
id::qualified_name m_qualifiedName;
id::c::qualified_name m_qualifiedName;

/// @brief The value of this entry.
std::string m_value;
Expand All @@ -61,14 +61,14 @@ struct ConfigEntry
/// @brief Construct this entry.
/// @param qualifiedName the qualified name
/// @param value the value
ConfigEntry(const id::qualified_name& qualifiedName, const std::string& value);
ConfigEntry(const id::c::qualified_name& qualifiedName, const std::string& value);

/// @brief Destruct this entry.
virtual ~ConfigEntry();

/// @brief Get the qualified name of this entry.
/// @return the qualified name of this entry
const id::qualified_name& getQualifiedName() const;
const id::c::qualified_name& getQualifiedName() const;

/// @brief Get the value of this entry.
/// @return the value of this entry
Expand All @@ -85,7 +85,7 @@ struct AbstractConfigFile
{
public:

using MapTy = std::unordered_map<id::qualified_name, std::shared_ptr<ConfigEntry>>;
using MapTy = std::unordered_map<id::c::qualified_name, std::shared_ptr<ConfigEntry>>;
using ConstMapIteratorTy = MapTy::const_iterator;

/// @internal Custom iterator.
Expand Down Expand Up @@ -185,7 +185,7 @@ struct AbstractConfigFile
* @brief
* A map of qualified names (keys) to shared pointers of entries (values).
*/
std::unordered_map<id::qualified_name,std::shared_ptr<ConfigEntry>> _map;
std::unordered_map<id::c::qualified_name,std::shared_ptr<ConfigEntry>> _map;

public:

Expand Down Expand Up @@ -269,7 +269,7 @@ struct AbstractConfigFile
* @return
* @a true on success, @a false on failure
*/
bool set(const id::qualified_name& qn, const std::string& v)
bool set(const id::c::qualified_name& qn, const std::string& v)
{
try
{
Expand All @@ -294,7 +294,7 @@ struct AbstractConfigFile
* If @a true is returned, the value was stored @a v.
* the value if it exists, @a nullptr otherwise
*/
bool get(const id::qualified_name& qn, std::string& v) const
bool get(const id::c::qualified_name& qn, std::string& v) const
{
auto it = _map.find(qn);
if (it != _map.end())
Expand Down Expand Up @@ -404,7 +404,7 @@ struct ConfigFileParser : public Ego::Script::Scanner<Ego::Script::Traits<char>>
* @brief
* The current qualified name or @a nullptr.
*/
std::unique_ptr<id::qualified_name> _currentQualifiedName;
std::unique_ptr<id::c::qualified_name> _currentQualifiedName;
/**
* @brief
* The current value or @a nullptr.
Expand Down
24 changes: 12 additions & 12 deletions egolib/src/egolib/FileFormats/SpawnFile/SpawnFileReaderImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,17 @@ bool SpawnFileReaderImpl::read(ReadContext& ctxt, spawn_file_info_t& info)
} while (!ctxt.is(':') && !ctxt.ise(ctxt.NEW_LINE()) && !ctxt.ise(ctxt.END_OF_INPUT()) && !ctxt.ise(ctxt.ERROR()));
if (ctxt.ise(ctxt.ERROR()))
{
throw id::compilation_error(__FILE__, __LINE__, id::compilation_error_kind::lexical, ctxt.get_location(),
"read error");
throw id::c::compilation_error(__FILE__, __LINE__, id::c::compilation_error_kind::lexical, ctxt.get_location(),
"read error");
}
if (ctxt.ise(ctxt.END_OF_INPUT()))
{
return false;
}
if (!ctxt.is(':'))
{
throw id::compilation_error(__FILE__, __LINE__, id::compilation_error_kind::lexical, ctxt.get_location(),
"expected `:`");
throw id::c::compilation_error(__FILE__, __LINE__, id::c::compilation_error_kind::lexical, ctxt.get_location(),
"expected `:`");
}
ctxt.next();

Expand Down Expand Up @@ -83,8 +83,8 @@ bool SpawnFileReaderImpl::read(ReadContext& ctxt, spawn_file_info_t& info)
case 'I': info.attach = ATTACH_INVENTORY; break;
default:
{
throw id::compilation_error(__FILE__, __LINE__, id::compilation_error_kind::syntactical, ctxt.get_location(),
"invalid enumeration element");
throw id::c::compilation_error(__FILE__, __LINE__, id::c::compilation_error_kind::syntactical, ctxt.get_location(),
"invalid enumeration element");
}
};
info.money = ctxt.readIntegerLiteral();
Expand Down Expand Up @@ -121,8 +121,8 @@ bool SpawnFileReaderImpl::read(ReadContext& ctxt, spawn_file_info_t& info)
std::string what = ctxt.readName();
if (what != "dependency")
{
throw id::compilation_error(__FILE__, __LINE__, id::compilation_error_kind::syntactical, ctxt.get_location(),
"syntax error");
throw id::c::compilation_error(__FILE__, __LINE__, id::c::compilation_error_kind::syntactical, ctxt.get_location(),
"syntax error");
}
std::string who;
ctxt.skipWhiteSpaces();
Expand All @@ -136,8 +136,8 @@ bool SpawnFileReaderImpl::read(ReadContext& ctxt, spawn_file_info_t& info)
}
if (who.empty()) /// @todo Verify that this is unnecessary based on the definition of readName.
{
throw id::compilation_error(__FILE__, __LINE__, id::compilation_error_kind::syntactical, ctxt.get_location(),
"syntax error");
throw id::c::compilation_error(__FILE__, __LINE__, id::c::compilation_error_kind::syntactical, ctxt.get_location(),
"syntax error");
}
int slot = ctxt.readIntegerLiteral();
// Store the data.
Expand All @@ -147,8 +147,8 @@ bool SpawnFileReaderImpl::read(ReadContext& ctxt, spawn_file_info_t& info)
}
else if (!ctxt.ise(ctxt.END_OF_INPUT()))
{
throw id::compilation_error(__FILE__, __LINE__, id::compilation_error_kind::lexical, ctxt.get_location(),
"junk after end of spawn file");
throw id::c::compilation_error(__FILE__, __LINE__, id::c::compilation_error_kind::lexical, ctxt.get_location(),
"junk after end of spawn file");
}
return false;
}
Expand Down
Loading

0 comments on commit 02b20f6

Please sign in to comment.