diff --git a/intern/string/STR_String.h b/intern/string/STR_String.h index 4607db45c7c6..2053163db03a 100644 --- a/intern/string/STR_String.h +++ b/intern/string/STR_String.h @@ -46,6 +46,7 @@ #endif #include +#include // Compatibility #include #include @@ -81,6 +82,7 @@ class STR_String STR_String(const STR_String &str); STR_String(const STR_String & str, int len); STR_String(const char *src1, int src1_len, const char *src2, int src2_len); + STR_String(const std::string& s); // Compatibility explicit STR_String(int val); explicit STR_String(dword val); explicit STR_String(float val); diff --git a/intern/string/intern/STR_String.cpp b/intern/string/intern/STR_String.cpp index 4ea451311e4b..c66670e1f5ec 100644 --- a/intern/string/intern/STR_String.cpp +++ b/intern/string/intern/STR_String.cpp @@ -175,7 +175,15 @@ STR_String::STR_String(const char *src1, int len1, const char *src2, int len2) : this->m_data[len1 + len2] = 0; } - +STR_String::STR_String(const std::string& s) : + m_data(new char[s.size() + 8]), + m_len(s.size()), + m_max(s.size() + 8) +{ + assertd(this->m_data != NULL); + memcpy(this->m_data, s.c_str(), s.size()); + this->m_data[s.size()] = 0; +} // // Create a string with an integer value diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp index ff9f8f921c8a..306d347f1dd1 100644 --- a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp +++ b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp @@ -88,12 +88,12 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, rcti *c char* startscenename = startscene->id.name + 2; char pathname[FILE_MAXDIR+FILE_MAXFILE]; - STR_String exitstring = ""; + std::string exitstring = ""; BlendFileData *bfd = NULL; BLI_strncpy(pathname, blenderdata->name, sizeof(pathname)); - KX_SetOrigPath(STR_String(blenderdata->name)); + KX_SetOrigPath(std::string(blenderdata->name)); #ifdef WITH_PYTHON @@ -121,8 +121,8 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, rcti *c // base the actuator filename with respect // to the original file working directory - if (exitstring != "") { - BLI_strncpy(basedpath, exitstring.ReadPtr(), sizeof(basedpath)); + if (!exitstring.empty()) { + BLI_strncpy(basedpath, exitstring.c_str(), sizeof(basedpath)); } // load relative to the last loaded file, this used to be relative diff --git a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp index 08986e3f60aa..3fac2260149a 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp +++ b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp @@ -257,7 +257,7 @@ void KX_BlenderCanvas::SetMousePosition(int x, int y) WM_cursor_warp(m_win, winX + x + 1, winY + (winH - y - 1)); } -void KX_BlenderCanvas::MakeScreenShot(const char *filename) +void KX_BlenderCanvas::MakeScreenShot(const std::string& filename) { unsigned int *pixeldata; bScreen *screen = m_win->screen; @@ -286,8 +286,8 @@ void KX_BlenderCanvas::MakeScreenShot(const char *filename) // create file path char path[FILE_MAX]; - BLI_strncpy(path, filename, FILE_MAX); - BLI_path_abs(path, KX_GetMainPath().ReadPtr()); + BLI_strncpy(path, filename.c_str(), FILE_MAX); + BLI_path_abs(path, KX_GetMainPath().c_str()); /* save_screenshot() frees dumprect and im_format */ save_screenshot(path, width, height, pixeldata, im_format); diff --git a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h index 612d6745db05..e0c0c7f23c1f 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h +++ b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h @@ -110,7 +110,7 @@ class KX_BlenderCanvas : public RAS_ICanvas virtual void SetMouseState(RAS_MouseState mousestate); virtual void SetMousePosition(int x, int y); - virtual void MakeScreenShot(const char *filename); + virtual void MakeScreenShot(const std::string& filename); virtual void BeginDraw(); virtual void EndDraw(); diff --git a/source/gameengine/Converter/BL_ActionActuator.cpp b/source/gameengine/Converter/BL_ActionActuator.cpp index 080068f084db..2be4cea1cd1f 100644 --- a/source/gameengine/Converter/BL_ActionActuator.cpp +++ b/source/gameengine/Converter/BL_ActionActuator.cpp @@ -37,7 +37,7 @@ #include "BL_Action.h" #include "BL_ActionManager.h" #include "KX_GameObject.h" -#include "STR_HashedString.h" +#include #include "MEM_guardedalloc.h" #include "DNA_nla_types.h" #include "DNA_action_types.h" @@ -61,8 +61,8 @@ extern "C" { } BL_ActionActuator::BL_ActionActuator(SCA_IObject *gameobj, - const STR_String& propname, - const STR_String& framepropname, + const std::string& propname, + const std::string& framepropname, float starttime, float endtime, struct bAction *action, @@ -560,7 +560,7 @@ PyAttributeDef BL_ActionActuator::Attributes[] = { KX_PYATTRIBUTE_RW_FUNCTION("useContinue", BL_ActionActuator, pyattr_get_use_continue, pyattr_set_use_continue), KX_PYATTRIBUTE_FLOAT_RW_CHECK("blendTime", 0, MAXFRAMEF, BL_ActionActuator, m_blendframe, CheckBlendTime), KX_PYATTRIBUTE_SHORT_RW_CHECK("mode",0,100,false,BL_ActionActuator,m_playtype,CheckType), - { NULL } //Sentinel + KX_PYATTRIBUTE_NULL //Sentinel }; PyObject *BL_ActionActuator::pyattr_get_action(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) @@ -580,7 +580,7 @@ int BL_ActionActuator::pyattr_set_action(void *self_v, const KX_PYATTRIBUTE_DEF } bAction *action= NULL; - STR_String val = _PyUnicode_AsString(value); + std::string val = _PyUnicode_AsString(value); if (val != "") { diff --git a/source/gameengine/Converter/BL_ActionActuator.h b/source/gameengine/Converter/BL_ActionActuator.h index 133740cb05b2..ee757b42dd46 100644 --- a/source/gameengine/Converter/BL_ActionActuator.h +++ b/source/gameengine/Converter/BL_ActionActuator.h @@ -41,8 +41,8 @@ class BL_ActionActuator : public SCA_IActuator public: Py_Header BL_ActionActuator(SCA_IObject* gameobj, - const STR_String& propname, - const STR_String& framepropname, + const std::string& propname, + const std::string& framepropname, float starttime, float endtime, struct bAction *action, @@ -136,8 +136,8 @@ class BL_ActionActuator : public SCA_IActuator short m_layer; short m_ipo_flags; struct bAction *m_action; - STR_String m_propname; - STR_String m_framepropname; + std::string m_propname; + std::string m_framepropname; }; enum { diff --git a/source/gameengine/Converter/BL_ArmatureActuator.cpp b/source/gameengine/Converter/BL_ArmatureActuator.cpp index a551a9561006..815cd64825f6 100644 --- a/source/gameengine/Converter/BL_ArmatureActuator.cpp +++ b/source/gameengine/Converter/BL_ArmatureActuator.cpp @@ -224,13 +224,13 @@ PyAttributeDef BL_ArmatureActuator::Attributes[] = { KX_PYATTRIBUTE_FLOAT_RW("weight",0.0f,1.0f,BL_ArmatureActuator,m_weight), KX_PYATTRIBUTE_FLOAT_RW("influence",0.0f,1.0f,BL_ArmatureActuator,m_influence), KX_PYATTRIBUTE_INT_RW("type",0,ACT_ARM_MAXTYPE,false,BL_ArmatureActuator,m_type), - { NULL } //Sentinel + KX_PYATTRIBUTE_NULL //Sentinel }; PyObject *BL_ArmatureActuator::pyattr_get_object(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef) { BL_ArmatureActuator* actuator = static_cast(self); - KX_GameObject *target = (!strcmp(attrdef->m_name, "target")) ? actuator->m_gametarget : actuator->m_gamesubtarget; + KX_GameObject *target = (attrdef->m_name == "target") ? actuator->m_gametarget : actuator->m_gamesubtarget; if (!target) Py_RETURN_NONE; else @@ -240,7 +240,7 @@ PyObject *BL_ArmatureActuator::pyattr_get_object(void *self, const struct KX_PYA int BL_ArmatureActuator::pyattr_set_object(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) { BL_ArmatureActuator* actuator = static_cast(self); - KX_GameObject* &target = (!strcmp(attrdef->m_name, "target")) ? actuator->m_gametarget : actuator->m_gamesubtarget; + KX_GameObject* &target = (attrdef->m_name == "target") ? actuator->m_gametarget : actuator->m_gamesubtarget; KX_GameObject *gameobj; if (!ConvertPythonToGameObject(actuator->GetLogicManager(), value, &gameobj, true, "actuator.object = value: BL_ArmatureActuator")) diff --git a/source/gameengine/Converter/BL_ArmatureActuator.h b/source/gameengine/Converter/BL_ArmatureActuator.h index 72c969d87525..9a6a636b54b5 100644 --- a/source/gameengine/Converter/BL_ArmatureActuator.h +++ b/source/gameengine/Converter/BL_ArmatureActuator.h @@ -86,8 +86,8 @@ class BL_ArmatureActuator : public SCA_IActuator BL_ArmatureConstraint* m_constraint; KX_GameObject* m_gametarget; KX_GameObject* m_gamesubtarget; - STR_String m_posechannel; - STR_String m_constraintname; + std::string m_posechannel; + std::string m_constraintname; float m_weight; float m_influence; int m_type; diff --git a/source/gameengine/Converter/BL_ArmatureChannel.cpp b/source/gameengine/Converter/BL_ArmatureChannel.cpp index 2b8dfd8f8d1e..d8cd3d187157 100644 --- a/source/gameengine/Converter/BL_ArmatureChannel.cpp +++ b/source/gameengine/Converter/BL_ArmatureChannel.cpp @@ -106,8 +106,7 @@ PyAttributeDef BL_ArmatureChannel::Attributes[] = { // Keep these attributes in order of BCA_ defines!!! used by py_attr_getattr and py_attr_setattr KX_PYATTRIBUTE_RO_FUNCTION("bone",BL_ArmatureChannel,py_attr_getattr), KX_PYATTRIBUTE_RO_FUNCTION("parent",BL_ArmatureChannel,py_attr_getattr), - - { NULL } //Sentinel + KX_PYATTRIBUTE_NULL //Sentinel }; /* attributes directly taken from bPoseChannel */ @@ -144,7 +143,7 @@ PyAttributeDef BL_ArmatureChannel::AttributesPtr[] = { KX_PYATTRIBUTE_FLOAT_RW("ik_rot_weight",0,1.0f,bPoseChannel,ikrotweight), KX_PYATTRIBUTE_FLOAT_RW("ik_lin_weight",0,1.0f,bPoseChannel,iklinweight), KX_PYATTRIBUTE_RW_FUNCTION("joint_rotation",BL_ArmatureChannel,py_attr_get_joint_rotation,py_attr_set_joint_rotation), - { NULL } //Sentinel + KX_PYATTRIBUTE_NULL //Sentinel }; PyObject *BL_ArmatureChannel::py_attr_getattr(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef) @@ -417,7 +416,7 @@ PyMethodDef BL_ArmatureBone::Methods[] = { /* no attributes on C++ class since it is never instantiated */ PyAttributeDef BL_ArmatureBone::Attributes[] = { - { NULL } //Sentinel + KX_PYATTRIBUTE_NULL //Sentinel }; // attributes that work on proxy ptr (points to a Bone structure) @@ -437,7 +436,7 @@ PyAttributeDef BL_ArmatureBone::AttributesPtr[] = { KX_PYATTRIBUTE_FLOAT_MATRIX_RO("bone_mat",Bone,bone_mat,3), KX_PYATTRIBUTE_RO_FUNCTION("parent",BL_ArmatureBone,py_bone_get_parent), KX_PYATTRIBUTE_RO_FUNCTION("children",BL_ArmatureBone,py_bone_get_children), - { NULL } //Sentinel + KX_PYATTRIBUTE_NULL //Sentinel }; PyObject *BL_ArmatureBone::py_bone_get_parent(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef) diff --git a/source/gameengine/Converter/BL_ArmatureConstraint.cpp b/source/gameengine/Converter/BL_ArmatureConstraint.cpp index 03ecdb207496..64ae29f84643 100644 --- a/source/gameengine/Converter/BL_ArmatureConstraint.cpp +++ b/source/gameengine/Converter/BL_ArmatureConstraint.cpp @@ -64,7 +64,7 @@ PyTypeObject BL_ArmatureConstraint::Type = { PyObject *BL_ArmatureConstraint::py_repr(void) { - return PyUnicode_FromString(m_name); + return PyUnicode_FromStdString(m_name); } #endif // WITH_PYTHON @@ -96,7 +96,7 @@ BL_ArmatureConstraint::BL_ArmatureConstraint( m_target->RegisterObject(m_armature); if (m_subtarget) m_subtarget->RegisterObject(m_armature); - BLI_snprintf(m_name, sizeof(m_name), "%s:%s", m_posechannel->name, m_constraint->name); + m_name = std::string(m_posechannel->name) + ":" + std::string(m_constraint->name); } BL_ArmatureConstraint::~BL_ArmatureConstraint() @@ -211,9 +211,9 @@ void BL_ArmatureConstraint::RestoreTarget() } } -bool BL_ArmatureConstraint::Match(const char* posechannel, const char* constraint) +bool BL_ArmatureConstraint::Match(const std::string& posechannel, const std::string& constraint) { - return (!strcmp(m_posechannel->name, posechannel) && !strcmp(m_constraint->name, constraint)); + return ((m_posechannel->name == posechannel) && (m_constraint->name == constraint)); } void BL_ArmatureConstraint::SetTarget(KX_GameObject* target) @@ -282,8 +282,7 @@ PyAttributeDef BL_ArmatureConstraint::Attributes[] = { KX_PYATTRIBUTE_RO_FUNCTION("ik_flag",BL_ArmatureConstraint,py_attr_getattr), KX_PYATTRIBUTE_RW_FUNCTION("ik_dist",BL_ArmatureConstraint,py_attr_getattr,py_attr_setattr), KX_PYATTRIBUTE_RW_FUNCTION("ik_mode",BL_ArmatureConstraint,py_attr_getattr,py_attr_setattr), - - { NULL } //Sentinel + KX_PYATTRIBUTE_NULL //Sentinel }; diff --git a/source/gameengine/Converter/BL_ArmatureConstraint.h b/source/gameengine/Converter/BL_ArmatureConstraint.h index 10304ee8b60a..beb9af6b679e 100644 --- a/source/gameengine/Converter/BL_ArmatureConstraint.h +++ b/source/gameengine/Converter/BL_ArmatureConstraint.h @@ -59,7 +59,7 @@ class BL_ArmatureConstraint : public PyObjectPlus, public SG_QList struct bConstraint* m_constraint; struct bPoseChannel* m_posechannel; class BL_ArmatureObject* m_armature; - char m_name[64]; + std::string m_name; KX_GameObject* m_target; KX_GameObject* m_subtarget; struct Object* m_blendtarget; @@ -85,8 +85,8 @@ class BL_ArmatureConstraint : public PyObjectPlus, public SG_QList void UpdateTarget(); void RestoreTarget(); - bool Match(const char* posechannel, const char* constraint); - const char* GetName() { return m_name; } + bool Match(const std::string& posechannel, const std::string& constraint); + const std::string& GetName() { return m_name; } void SetConstraintFlag(int flag) { diff --git a/source/gameengine/Converter/BL_ArmatureObject.cpp b/source/gameengine/Converter/BL_ArmatureObject.cpp index b05ba0c9c498..c87b9025acf6 100644 --- a/source/gameengine/Converter/BL_ArmatureObject.cpp +++ b/source/gameengine/Converter/BL_ArmatureObject.cpp @@ -343,7 +343,7 @@ void BL_ArmatureObject::LoadConstraints(KX_BlenderSceneConverter* converter) GetActionManager(); } -BL_ArmatureConstraint* BL_ArmatureObject::GetConstraint(const char* posechannel, const char* constraintname) +BL_ArmatureConstraint* BL_ArmatureObject::GetConstraint(const std::string& posechannel, const std::string& constraintname) { SG_DList::iterator cit(m_controlledConstraints); for (cit.begin(); !cit.end(); ++cit) { @@ -354,13 +354,13 @@ BL_ArmatureConstraint* BL_ArmatureObject::GetConstraint(const char* posechannel, return NULL; } -BL_ArmatureConstraint* BL_ArmatureObject::GetConstraint(const char* posechannelconstraint) +BL_ArmatureConstraint* BL_ArmatureObject::GetConstraint(const std::string& posechannelconstraint) { // performance: use hash string instead of plain string compare SG_DList::iterator cit(m_controlledConstraints); for (cit.begin(); !cit.end(); ++cit) { BL_ArmatureConstraint* constraint = *cit; - if (!strcmp(constraint->GetName(), posechannelconstraint)) + if (constraint->GetName() == posechannelconstraint) return constraint; } return NULL; @@ -402,14 +402,14 @@ BL_ArmatureChannel* BL_ArmatureObject::GetChannel(bPoseChannel* pchan) return NULL; } -BL_ArmatureChannel* BL_ArmatureObject::GetChannel(const char* str) +BL_ArmatureChannel* BL_ArmatureObject::GetChannel(const std::string& str) { LoadChannels(); SG_DList::iterator cit(m_poseChannels); for (cit.begin(); !cit.end(); ++cit) { BL_ArmatureChannel* channel = *cit; - if (!strcmp(channel->m_posechannel->name, str)) + if (channel->m_posechannel->name == str) return channel; } return NULL; @@ -641,7 +641,7 @@ PyAttributeDef BL_ArmatureObject::Attributes[] = { KX_PYATTRIBUTE_RO_FUNCTION("constraints", BL_ArmatureObject, pyattr_get_constraints), KX_PYATTRIBUTE_RO_FUNCTION("channels", BL_ArmatureObject, pyattr_get_channels), - {NULL} //Sentinel + KX_PYATTRIBUTE_NULL //Sentinel }; static int bl_armature_object_get_constraints_size_cb(void *self_v) @@ -654,7 +654,7 @@ static PyObject *bl_armature_object_get_constraints_item_cb(void *self_v, int in return ((BL_ArmatureObject *)self_v)->GetConstraint(index)->GetProxy(); } -static const char *bl_armature_object_get_constraints_item_name_cb(void *self_v, int index) +static const std::string bl_armature_object_get_constraints_item_name_cb(void *self_v, int index) { return ((BL_ArmatureObject *)self_v)->GetConstraint(index)->GetName(); } @@ -680,7 +680,7 @@ static PyObject *bl_armature_object_get_channels_item_cb(void *self_v, int index return ((BL_ArmatureObject *)self_v)->GetChannel(index)->GetProxy(); } -static const char *bl_armature_object_get_channels_item_name_cb(void *self_v, int index) +static const std::string bl_armature_object_get_channels_item_name_cb(void *self_v, int index) { return ((BL_ArmatureObject *)self_v)->GetChannel(index)->GetName(); } diff --git a/source/gameengine/Converter/BL_ArmatureObject.h b/source/gameengine/Converter/BL_ArmatureObject.h index 449b0e9aa6e7..28e4fb42c84a 100644 --- a/source/gameengine/Converter/BL_ArmatureObject.h +++ b/source/gameengine/Converter/BL_ArmatureObject.h @@ -94,14 +94,14 @@ class BL_ArmatureObject : public KX_GameObject // for constraint python API void LoadConstraints(KX_BlenderSceneConverter* converter); size_t GetConstraintNumber() const { return m_constraintNumber; } - BL_ArmatureConstraint* GetConstraint(const char* posechannel, const char* constraint); - BL_ArmatureConstraint* GetConstraint(const char* posechannelconstraint); + BL_ArmatureConstraint* GetConstraint(const std::string& posechannel, const std::string& constraint); + BL_ArmatureConstraint* GetConstraint(const std::string& posechannelconstraint); BL_ArmatureConstraint* GetConstraint(int index); // for pose channel python API void LoadChannels(); size_t GetChannelNumber() const { return m_channelNumber; } BL_ArmatureChannel* GetChannel(bPoseChannel* channel); - BL_ArmatureChannel* GetChannel(const char* channel); + BL_ArmatureChannel* GetChannel(const std::string& channel); BL_ArmatureChannel* GetChannel(int index); /// Retrieve the pose matrix for the specified bone. diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index cef2237780f1..a839b808e998 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -478,8 +478,8 @@ RAS_MeshObject* BL_ConvertMesh(Mesh* mesh, Object* blenderobj, KX_Scene* scene, // Without checking names, we get some reuse we don't want that can cause // problems with material LoDs. if (blenderobj && ((meshobj = converter->FindGameMesh(mesh/*, ob->lay*/)) != NULL)) { - const STR_String bge_name = meshobj->GetName(); - const STR_String blender_name = ((ID *)blenderobj->data)->name + 2; + const std::string bge_name = meshobj->GetName(); + const std::string blender_name = ((ID *)blenderobj->data)->name + 2; if (bge_name == blender_name) { return meshobj; } @@ -1198,7 +1198,7 @@ static void blenderSceneSetBackground(Scene *blenderscene) } } -static KX_GameObject* getGameOb(STR_String busc,CListValue* sumolist) +static KX_GameObject* getGameOb(std::string busc,CListValue* sumolist) { for (CListValue::iterator it = sumolist->GetBegin(), end = sumolist->GetEnd(); it != end; ++it) { KX_GameObject *gameobje = *it; diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.h b/source/gameengine/Converter/BL_BlenderDataConversion.h index 2d033793a0c4..91922be1b9de 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.h +++ b/source/gameengine/Converter/BL_BlenderDataConversion.h @@ -32,7 +32,7 @@ #ifndef __BL_BLENDERDATACONVERSION_H__ #define __BL_BLENDERDATACONVERSION_H__ -#include "STR_String.h" +#include #include "EXP_Python.h" #include "KX_PhysicsEngineEnums.h" #include "SCA_IInputDevice.h" diff --git a/source/gameengine/Converter/BL_MeshDeformer.cpp b/source/gameengine/Converter/BL_MeshDeformer.cpp index 8cc2f8b20b7c..43d4d0db2eb5 100644 --- a/source/gameengine/Converter/BL_MeshDeformer.cpp +++ b/source/gameengine/Converter/BL_MeshDeformer.cpp @@ -46,7 +46,7 @@ #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" -#include "STR_HashedString.h" +#include #include "BLI_math.h" bool BL_MeshDeformer::Apply(RAS_IPolyMaterial *UNUSED(polymat), RAS_MeshMaterial *UNUSED(meshmat)) diff --git a/source/gameengine/Converter/BL_ModifierDeformer.cpp b/source/gameengine/Converter/BL_ModifierDeformer.cpp index e203eca0b6e4..66ec1d30db33 100644 --- a/source/gameengine/Converter/BL_ModifierDeformer.cpp +++ b/source/gameengine/Converter/BL_ModifierDeformer.cpp @@ -35,7 +35,7 @@ #include "MEM_guardedalloc.h" #include "BL_ModifierDeformer.h" -#include "STR_HashedString.h" +#include #include "RAS_IPolygonMaterial.h" #include "RAS_MeshObject.h" #include "RAS_BoundingBox.h" diff --git a/source/gameengine/Converter/BL_ShapeDeformer.cpp b/source/gameengine/Converter/BL_ShapeDeformer.cpp index 3ba8f34524db..f7fa35a75aff 100644 --- a/source/gameengine/Converter/BL_ShapeDeformer.cpp +++ b/source/gameengine/Converter/BL_ShapeDeformer.cpp @@ -35,7 +35,7 @@ #include "MEM_guardedalloc.h" #include "BL_ShapeDeformer.h" -#include "STR_HashedString.h" +#include #include "RAS_IPolygonMaterial.h" #include "RAS_MeshObject.h" diff --git a/source/gameengine/Converter/BL_SkinDeformer.cpp b/source/gameengine/Converter/BL_SkinDeformer.cpp index 56301002b7a7..e847f3bb7c93 100644 --- a/source/gameengine/Converter/BL_SkinDeformer.cpp +++ b/source/gameengine/Converter/BL_SkinDeformer.cpp @@ -38,7 +38,7 @@ #include #include "BL_SkinDeformer.h" -#include "STR_HashedString.h" +#include #include "RAS_IPolygonMaterial.h" #include "RAS_DisplayArray.h" #include "RAS_MeshObject.h" diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp index 18ea73146e9d..5af3a9109829 100644 --- a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp +++ b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp @@ -177,7 +177,7 @@ KX_BlenderSceneConverter::~KX_BlenderSceneConverter() } } -void KX_BlenderSceneConverter::SetNewFileName(const STR_String &filename) +void KX_BlenderSceneConverter::SetNewFileName(const std::string &filename) { m_newfilename = filename; } @@ -189,19 +189,19 @@ bool KX_BlenderSceneConverter::TryAndLoadNewFile() return result; } -Scene *KX_BlenderSceneConverter::GetBlenderSceneForName(const STR_String &name) +Scene *KX_BlenderSceneConverter::GetBlenderSceneForName(const std::string &name) { Scene *sce; // Find the specified scene by name, or NULL if nothing matches. - if ((sce = (Scene *)BLI_findstring(&m_maggie->scene, name.ReadPtr(), offsetof(ID, name) + 2))) { + if ((sce = (Scene *)BLI_findstring(&m_maggie->scene, name.c_str(), offsetof(ID, name) + 2))) { return sce; } for (std::vector
::iterator it = m_DynamicMaggie.begin(); !(it == m_DynamicMaggie.end()); it++) { Main *main = *it; - if ((sce = (Scene *)BLI_findstring(&main->scene, name.ReadPtr(), offsetof(ID, name) + 2))) { + if ((sce = (Scene *)BLI_findstring(&main->scene, name.c_str(), offsetof(ID, name) + 2))) { return sce; } } @@ -752,9 +752,9 @@ bool KX_BlenderSceneConverter::FreeBlendFile(Main *maggie) else { // in case the mesh might be refered to later { - std::map &mapStringToMeshes = scene->GetLogicManager()->GetMeshMap(); + std::map &mapStringToMeshes = scene->GetLogicManager()->GetMeshMap(); - for (std::map::iterator it = mapStringToMeshes.begin(), + for (std::map::iterator it = mapStringToMeshes.begin(), end = mapStringToMeshes.end(); it != end; ) { RAS_MeshObject *meshobj = (RAS_MeshObject *)it->second; @@ -770,9 +770,9 @@ bool KX_BlenderSceneConverter::FreeBlendFile(Main *maggie) // Now unregister actions. { - std::map &mapStringToActions = scene->GetLogicManager()->GetActionMap(); + std::map &mapStringToActions = scene->GetLogicManager()->GetActionMap(); - for (std::map::iterator it = mapStringToActions.begin(), + for (std::map::iterator it = mapStringToActions.begin(), end = mapStringToActions.end(); it != end; ) { ID *action = (ID *)it->second; diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.h b/source/gameengine/Converter/KX_BlenderSceneConverter.h index 95fee35e7f02..fd458f6ff167 100644 --- a/source/gameengine/Converter/KX_BlenderSceneConverter.h +++ b/source/gameengine/Converter/KX_BlenderSceneConverter.h @@ -41,6 +41,7 @@ #include "CM_Message.h" #include +#include class KX_WorldInfo; class KX_KetsjiEngine; @@ -88,7 +89,7 @@ class KX_BlenderSceneConverter : public KX_ISceneConverter Main *m_maggie; std::vector
m_DynamicMaggie; - STR_String m_newfilename; + std::string m_newfilename; KX_KetsjiEngine *m_ketsjiEngine; bool m_alwaysUseExpandFraming; @@ -104,7 +105,7 @@ class KX_BlenderSceneConverter : public KX_ISceneConverter virtual void ConvertScene(KX_Scene *destinationscene, RAS_IRasterizer *rendertools, RAS_ICanvas *canvas, bool libloading = false); virtual void RemoveScene(KX_Scene *scene); - void SetNewFileName(const STR_String& filename); + void SetNewFileName(const std::string& filename); bool TryAndLoadNewFile(); void SetAlwaysUseExpandFraming(bool to_what); @@ -129,7 +130,7 @@ class KX_BlenderSceneConverter : public KX_ISceneConverter void RegisterGameController(SCA_IController *cont, bController *for_controller); SCA_IController *FindGameController(bController *for_controller); - Scene *GetBlenderSceneForName(const STR_String& name); + Scene *GetBlenderSceneForName(const std::string& name); virtual CListValue *GetInactiveSceneNames(); Main *GetMainDynamicPath(const char *path); diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp index cfc7b6d3c8ac..dd78d9c5fcae 100644 --- a/source/gameengine/Converter/KX_ConvertActuators.cpp +++ b/source/gameengine/Converter/KX_ConvertActuators.cpp @@ -140,8 +140,8 @@ void BL_ConvertActuators(const char* maggiename, bact = (bActuator*) blenderobject->actuators.first; while (bact) { - STR_String uniquename = bact->name; - STR_String objectname = gameobj->GetName(); + std::string uniquename = bact->name; + std::string objectname = gameobj->GetName(); SCA_IActuator* baseact = NULL; switch (bact->type) @@ -208,8 +208,8 @@ void BL_ConvertActuators(const char* maggiename, case ACT_ACTION: { bActionActuator* actact = (bActionActuator*) bact->data; - STR_String propname = actact->name; - STR_String propframe = actact->frameProp; + std::string propname = actact->name; + std::string propframe = actact->frameProp; short ipo_flags = 0; @@ -271,11 +271,11 @@ void BL_ConvertActuators(const char* maggiename, /* Get the name of the properties that objects must own that * we're sending to, if present */ - STR_String toPropName = msgAct->toPropName; + std::string toPropName = msgAct->toPropName; /* Get the Message Subject to send. */ - STR_String subject = msgAct->subject; + std::string subject = msgAct->subject; /* Get the bodyType */ @@ -284,7 +284,7 @@ void BL_ConvertActuators(const char* maggiename, /* Get the body (text message or property name whose value * we'll be sending, might be empty */ - const STR_String body = msgAct->body; + const std::string body = msgAct->body; KX_NetworkMessageActuator *tmpmsgact = new KX_NetworkMessageActuator( gameobj, // actuator controlling object @@ -656,7 +656,7 @@ void BL_ConvertActuators(const char* maggiename, case ACT_SCENE: { bSceneActuator *sceneact = (bSceneActuator *) bact->data; - STR_String nextSceneName(""); + std::string nextSceneName(""); KX_SceneActuator* tmpsceneact; int mode = KX_SceneActuator::KX_SCENE_NODEF; @@ -732,8 +732,8 @@ void BL_ConvertActuators(const char* maggiename, { bGameActuator *gameact = (bGameActuator *) bact->data; KX_GameActuator* tmpgameact; - STR_String filename = maggiename; - STR_String loadinganimationname = ""; + std::string filename = maggiename; + std::string loadinganimationname = ""; int mode = KX_GameActuator::KX_GAME_NODEF; switch (gameact->type) { diff --git a/source/gameengine/Converter/KX_ConvertControllers.cpp b/source/gameengine/Converter/KX_ConvertControllers.cpp index 1d9174c9c502..d7278938c5b4 100644 --- a/source/gameengine/Converter/KX_ConvertControllers.cpp +++ b/source/gameengine/Converter/KX_ConvertControllers.cpp @@ -146,8 +146,8 @@ void BL_ConvertControllers( case CONT_EXPRESSION: { bExpressionCont* bexpcont = (bExpressionCont*) bcontr->data; - STR_String expressiontext = STR_String(bexpcont->str); - if (expressiontext.Length() > 0) + std::string expressiontext = std::string(bexpcont->str); + if (!expressiontext.empty()) { gamecontroller = new SCA_ExpressionController(gameobj,expressiontext); } @@ -171,7 +171,7 @@ void BL_ConvertControllers( buf= txt_to_buf(pycont->text); if (buf) { - pyctrl->SetScriptText(STR_String(buf)); + pyctrl->SetScriptText(std::string(buf)); pyctrl->SetScriptName(pycont->text->id.name+2); MEM_freeN(buf); } @@ -180,7 +180,7 @@ void BL_ConvertControllers( } else { /* let the controller print any warnings here when importing */ - pyctrl->SetScriptText(STR_String(pycont->module)); + pyctrl->SetScriptText(std::string(pycont->module)); pyctrl->SetScriptName(pycont->module); /* will be something like module.func so using it as the name is OK */ if (pycont->flag & CONT_PY_DEBUG) { @@ -205,7 +205,7 @@ void BL_ConvertControllers( gamecontroller->SetExecutePriority(executePriority++); gamecontroller->SetBookmark((bcontr->flag & CONT_PRIO) != 0); gamecontroller->SetState(bcontr->state_mask); - STR_String uniquename = bcontr->name; + std::string uniquename = bcontr->name; uniquename += "#CONTR#"; uniqueint++; CIntValue* uniqueval = new CIntValue(uniqueint); diff --git a/source/gameengine/Converter/KX_ConvertProperties.cpp b/source/gameengine/Converter/KX_ConvertProperties.cpp index b2d7cd122e75..9f0260348c2a 100644 --- a/source/gameengine/Converter/KX_ConvertProperties.cpp +++ b/source/gameengine/Converter/KX_ConvertProperties.cpp @@ -134,7 +134,7 @@ void BL_ConvertProperties(Object* object,KX_GameObject* gameobj,SCA_TimeEventMan { if (show_debug_info && isInActiveLayer) { - scene->AddDebugProperty(gameobj,STR_String(prop->name)); + scene->AddDebugProperty(gameobj,prop->name); } // done with propval, release it propval->Release(); @@ -142,8 +142,8 @@ void BL_ConvertProperties(Object* object,KX_GameObject* gameobj,SCA_TimeEventMan #ifdef WITH_PYTHON /* Warn if we double up on attributes, this isn't quite right since it wont find inherited attributes however there arnt many */ - for (PyAttributeDef *attrdef = KX_GameObject::Attributes; attrdef->m_name; attrdef++) { - if (strcmp(prop->name, attrdef->m_name)==0) { + for (PyAttributeDef *attrdef = KX_GameObject::Attributes; !attrdef->m_name.empty(); attrdef++) { + if (prop->name == attrdef->m_name) { CM_Warning("user defined property name \"" << prop->name << "\" is also a python attribute for object \"" << object->id.name+2 << "\". Use ob[\"" << prop->name << "\"] syntax to avoid conflict"); break; @@ -165,7 +165,7 @@ void BL_ConvertProperties(Object* object,KX_GameObject* gameobj,SCA_TimeEventMan if (object->scaflag & OB_DEBUGSTATE && isInActiveLayer) { // reserve name for object state - scene->AddDebugProperty(gameobj,STR_String("__state__")); + scene->AddDebugProperty(gameobj, "__state__"); } /* Font Objects need to 'copy' the Font Object data body to ["Text"] */ @@ -183,27 +183,27 @@ void BL_ConvertTextProperty(Object* object, KX_FontObject* fontobj,SCA_TimeEvent if (!prop) return; Curve *curve = static_cast(object->data); - STR_String str = curve->str; + std::string str = curve->str; CValue* propval = NULL; switch (prop->type) { case GPROP_BOOL: { - int value = atoi(str); + int value = std::stoi(str); propval = new CBoolValue((bool)(value != 0)); tprop->SetValue(propval); break; } case GPROP_INT: { - int value = atoi(str); + int value = std::stoi(str); propval = new CIntValue(value); tprop->SetValue(propval); break; } case GPROP_FLOAT: { - float floatprop = (float)atof(str); + float floatprop = std::stof(str); propval = new CFloatValue(floatprop); tprop->SetValue(propval); break; @@ -216,7 +216,7 @@ void BL_ConvertTextProperty(Object* object, KX_FontObject* fontobj,SCA_TimeEvent } case GPROP_TIME: { - float floatprop = (float)atof(str); + float floatprop = std::stof(str); CValue* timeval = new CFloatValue(floatprop); // set a subproperty called 'timer' so that diff --git a/source/gameengine/Converter/KX_ConvertSensors.cpp b/source/gameengine/Converter/KX_ConvertSensors.cpp index 700227585db7..b4a475bd3a95 100644 --- a/source/gameengine/Converter/KX_ConvertSensors.cpp +++ b/source/gameengine/Converter/KX_ConvertSensors.cpp @@ -176,7 +176,7 @@ void BL_ConvertSensors(struct Object* blenderobject, bCollisionPulse = (blendercollisionsensor->mode & SENS_COLLISION_PULSE); - const STR_String touchPropOrMatName = bFindMaterial ? + const std::string touchPropOrMatName = bFindMaterial ? blendercollisionsensor->materialName : blendercollisionsensor->name; @@ -201,7 +201,7 @@ void BL_ConvertSensors(struct Object* blenderobject, /* Get our NetworkScene */ KX_NetworkMessageScene *NetworkScene = kxscene->GetNetworkMessageScene(); /* filter on the incoming subjects, might be empty */ - const STR_String subject = msgSens->subject; + const std::string subject = msgSens->subject; gamesensor = new KX_NetworkMessageSensor( eventmgr, // our eventmanager @@ -217,7 +217,7 @@ void BL_ConvertSensors(struct Object* blenderobject, if (eventmgr) { bNearSensor* blendernearsensor = (bNearSensor*)sens->data; - const STR_String nearpropertyname = (char *)blendernearsensor->name; + const std::string nearpropertyname = (char *)blendernearsensor->name; //DT_ShapeHandle shape = DT_Sphere(0.0); @@ -328,7 +328,7 @@ void BL_ConvertSensors(struct Object* blenderobject, /* give us a focus-aware sensor */ bool bFindMaterial = (bmouse->mode & SENS_COLLISION_MATERIAL); bool bXRay = (bmouse->flag & SENS_RAY_XRAY); - STR_String checkname = (bFindMaterial? bmouse->matname : bmouse->propname); + std::string checkname = (bFindMaterial? bmouse->matname : bmouse->propname); gamesensor = new KX_MouseFocusSensor(eventmgr, startx, @@ -353,9 +353,9 @@ void BL_ConvertSensors(struct Object* blenderobject, = logicmgr->FindEventManager(SCA_EventManager::BASIC_EVENTMGR); if (eventmgr) { - STR_String propname=blenderpropsensor->name; - STR_String propval=blenderpropsensor->value; - STR_String propmaxval=blenderpropsensor->maxvalue; + std::string propname=blenderpropsensor->name; + std::string propval=blenderpropsensor->value; + std::string propmaxval=blenderpropsensor->maxvalue; SCA_PropertySensor::KX_PROPSENSOR_TYPE propchecktype = SCA_PropertySensor::KX_PROPSENSOR_NODEF; @@ -401,7 +401,7 @@ void BL_ConvertSensors(struct Object* blenderobject, = logicmgr->FindEventManager(SCA_EventManager::ACTUATOR_EVENTMGR); if (eventmgr) { - STR_String propname=blenderactsensor->name; + std::string propname=blenderactsensor->name; gamesensor = new SCA_ActuatorSensor(eventmgr,gameobj,propname); } break; @@ -415,8 +415,8 @@ void BL_ConvertSensors(struct Object* blenderobject, = logicmgr->FindEventManager(SCA_EventManager::BASIC_EVENTMGR); if (eventmgr) { - STR_String bonename=blenderarmsensor->posechannel; - STR_String constraintname=blenderarmsensor->constraint; + std::string bonename=blenderarmsensor->posechannel; + std::string constraintname=blenderarmsensor->constraint; gamesensor = new KX_ArmatureSensor(eventmgr,gameobj,bonename,constraintname, blenderarmsensor->type, blenderarmsensor->value); } break; @@ -429,7 +429,7 @@ void BL_ConvertSensors(struct Object* blenderobject, if (eventmgr) { bRadarSensor* blenderradarsensor = (bRadarSensor*) sens->data; - const STR_String radarpropertyname = blenderradarsensor->name; + const std::string radarpropertyname = blenderradarsensor->name; int radaraxis = blenderradarsensor->axis; @@ -479,7 +479,7 @@ void BL_ConvertSensors(struct Object* blenderobject, bool bFindMaterial = (blenderraysensor->mode & SENS_COLLISION_MATERIAL); bool bXRay = (blenderraysensor->mode & SENS_RAY_XRAY); - STR_String checkname = (bFindMaterial? blenderraysensor->matname : blenderraysensor->propname); + std::string checkname = (bFindMaterial? blenderraysensor->matname : blenderraysensor->propname); // don't want to get rays of length 0.0 or so double distance = (blenderraysensor->range < 0.01f ? 0.01f : blenderraysensor->range); @@ -602,7 +602,7 @@ void BL_ConvertSensors(struct Object* blenderobject, if (gamesensor) { gamesensor->SetExecutePriority(executePriority++); - STR_String uniquename = sens->name; + std::string uniquename = sens->name; uniquename += "#SENS#"; uniqueint++; CIntValue* uniqueval = new CIntValue(uniqueint); diff --git a/source/gameengine/Converter/KX_LibLoadStatus.cpp b/source/gameengine/Converter/KX_LibLoadStatus.cpp index 66fcd9982699..916c3ea53029 100644 --- a/source/gameengine/Converter/KX_LibLoadStatus.cpp +++ b/source/gameengine/Converter/KX_LibLoadStatus.cpp @@ -30,7 +30,7 @@ KX_LibLoadStatus::KX_LibLoadStatus(class KX_BlenderSceneConverter* kx_converter, class KX_KetsjiEngine* kx_engine, class KX_Scene* merge_scene, - const char *path) : + const std::string& path) : m_converter(kx_converter), m_engine(kx_engine), m_mergescene(merge_scene), @@ -109,12 +109,12 @@ class KX_Scene *KX_LibLoadStatus::GetMergeScene() return m_mergescene; } -void KX_LibLoadStatus::SetLibName(const char *name) +void KX_LibLoadStatus::SetLibName(const std::string& name) { m_libname = name; } -const char *KX_LibLoadStatus::GetLibName() +const std::string& KX_LibLoadStatus::GetLibName() { return m_libname; } @@ -150,7 +150,7 @@ void KX_LibLoadStatus::AddProgress(float progress) PyMethodDef KX_LibLoadStatus::Methods[] = { - {NULL} //Sentinel + {NULL, NULL} //Sentinel }; PyAttributeDef KX_LibLoadStatus::Attributes[] = { @@ -160,7 +160,7 @@ PyAttributeDef KX_LibLoadStatus::Attributes[] = { KX_PYATTRIBUTE_STRING_RO("libraryName", KX_LibLoadStatus, m_libname), KX_PYATTRIBUTE_RO_FUNCTION("timeTaken", KX_LibLoadStatus, pyattr_get_timetaken), KX_PYATTRIBUTE_BOOL_RO("finished", KX_LibLoadStatus, m_finished), - { NULL } //Sentinel + KX_PYATTRIBUTE_NULL //Sentinel }; PyTypeObject KX_LibLoadStatus::Type = { diff --git a/source/gameengine/Converter/KX_LibLoadStatus.h b/source/gameengine/Converter/KX_LibLoadStatus.h index fd51bfddd85c..1a5563f50489 100644 --- a/source/gameengine/Converter/KX_LibLoadStatus.h +++ b/source/gameengine/Converter/KX_LibLoadStatus.h @@ -37,7 +37,7 @@ class KX_LibLoadStatus : public PyObjectPlus class KX_KetsjiEngine* m_engine; class KX_Scene* m_mergescene; void* m_data; - STR_String m_libname; + std::string m_libname; float m_progress; double m_starttime; @@ -55,7 +55,7 @@ class KX_LibLoadStatus : public PyObjectPlus KX_LibLoadStatus(class KX_BlenderSceneConverter* kx_converter, class KX_KetsjiEngine* kx_engine, class KX_Scene* merge_scene, - const char *path); + const std::string& path); void Finish(); // Called when the libload is done void RunFinishCallback(); @@ -65,8 +65,8 @@ class KX_LibLoadStatus : public PyObjectPlus class KX_KetsjiEngine *GetEngine(); class KX_Scene *GetMergeScene(); - void SetLibName(const char *name); - const char *GetLibName(); + void SetLibName(const std::string& name); + const std::string& GetLibName(); void SetData(void *data); void *GetData(); diff --git a/source/gameengine/Device/DEV_Joystick.cpp b/source/gameengine/Device/DEV_Joystick.cpp index 13f9fec1e33c..36646e8176ac 100644 --- a/source/gameengine/Device/DEV_Joystick.cpp +++ b/source/gameengine/Device/DEV_Joystick.cpp @@ -396,7 +396,7 @@ int DEV_Joystick::pAxisTest(int axisnum) #endif /* WITH_SDL */ } -const char *DEV_Joystick::GetName() +const std::string DEV_Joystick::GetName() { #ifdef WITH_SDL return (SDL_CHECK(SDL_GameControllerName)) ? SDL_GameControllerName(m_private->m_gamecontroller) : ""; diff --git a/source/gameengine/Device/DEV_Joystick.h b/source/gameengine/Device/DEV_Joystick.h index d375059d7581..89c1096f1ee9 100644 --- a/source/gameengine/Device/DEV_Joystick.h +++ b/source/gameengine/Device/DEV_Joystick.h @@ -48,6 +48,8 @@ # endif #endif +#include + /** * Basic Joystick class * I will make this class a singleton because there should be only one joystick @@ -185,7 +187,7 @@ class DEV_Joystick /** * Name of the joytsick */ - const char *GetName(); + const std::string GetName(); }; #endif // __DEV_JOYSTICK_H__ diff --git a/source/gameengine/Expressions/CMakeLists.txt b/source/gameengine/Expressions/CMakeLists.txt index 29406bb2a32b..420d421cb95f 100644 --- a/source/gameengine/Expressions/CMakeLists.txt +++ b/source/gameengine/Expressions/CMakeLists.txt @@ -35,6 +35,7 @@ set(INC set(INC_SYS ../../../intern/moto/include + ${BOOST_INCLUDE_DIR} ) set(SRC diff --git a/source/gameengine/Expressions/EXP_BoolValue.h b/source/gameengine/Expressions/EXP_BoolValue.h index e2b6924b10ea..271cadd53f57 100644 --- a/source/gameengine/Expressions/EXP_BoolValue.h +++ b/source/gameengine/Expressions/EXP_BoolValue.h @@ -32,14 +32,14 @@ class CBoolValue : public CPropValue //PLUGIN_DECLARE_SERIAL(CBoolValue,CValue) public: - static const STR_String sTrueString; - static const STR_String sFalseString; + static const std::string sTrueString; + static const std::string sFalseString; CBoolValue(); CBoolValue(bool inBool); - CBoolValue(bool innie, const char *name, AllocationTYPE alloctype = CValue::HEAPVALUE); + CBoolValue(bool innie, const std::string& name, AllocationTYPE alloctype = CValue::HEAPVALUE); - virtual const STR_String GetText(); + virtual const std::string GetText(); virtual double GetNumber(); virtual int GetValueType(); bool GetBool(); diff --git a/source/gameengine/Expressions/EXP_EmptyValue.h b/source/gameengine/Expressions/EXP_EmptyValue.h index 6580d5846b91..6bc068e7d9b9 100644 --- a/source/gameengine/Expressions/EXP_EmptyValue.h +++ b/source/gameengine/Expressions/EXP_EmptyValue.h @@ -30,7 +30,7 @@ class CEmptyValue : public CPropValue CEmptyValue(); virtual ~CEmptyValue(); - virtual const STR_String GetText(); + virtual const std::string GetText(); virtual double GetNumber(); virtual int GetValueType(); CListValue* GetPolySoup(); diff --git a/source/gameengine/Expressions/EXP_ErrorValue.h b/source/gameengine/Expressions/EXP_ErrorValue.h index 5cc7f0db367d..1d384cb10a57 100644 --- a/source/gameengine/Expressions/EXP_ErrorValue.h +++ b/source/gameengine/Expressions/EXP_ErrorValue.h @@ -25,17 +25,17 @@ class CErrorValue : public CPropValue { public: - virtual const STR_String GetText(); + virtual const std::string GetText(); virtual int GetValueType(); CErrorValue(); - CErrorValue(const char *errmsg); + CErrorValue(const std::string& errmsg); virtual ~CErrorValue(); virtual CValue* Calc(VALUE_OPERATOR op, CValue* val); virtual CValue* CalcFinal(VALUE_DATA_TYPE dtype, VALUE_OPERATOR op, CValue *val); virtual CValue* GetReplica(); private: - STR_String m_strErrorText; + std::string m_strErrorText; #ifdef WITH_CXX_GUARDEDALLOC diff --git a/source/gameengine/Expressions/EXP_FloatValue.h b/source/gameengine/Expressions/EXP_FloatValue.h index 81f5a9075c39..f4aaff3ee3a5 100644 --- a/source/gameengine/Expressions/EXP_FloatValue.h +++ b/source/gameengine/Expressions/EXP_FloatValue.h @@ -27,9 +27,9 @@ class CFloatValue : public CPropValue public: CFloatValue(); CFloatValue(float fl); - CFloatValue(float fl,const char *name,AllocationTYPE alloctype=CValue::HEAPVALUE); + CFloatValue(float fl,const std::string& name,AllocationTYPE alloctype=CValue::HEAPVALUE); - virtual const STR_String GetText(); + virtual const std::string GetText(); void Configure(CValue* menuvalue); virtual double GetNumber(); diff --git a/source/gameengine/Expressions/EXP_IdentifierExpr.h b/source/gameengine/Expressions/EXP_IdentifierExpr.h index 96ef3677cf36..1fda1b016cc7 100644 --- a/source/gameengine/Expressions/EXP_IdentifierExpr.h +++ b/source/gameengine/Expressions/EXP_IdentifierExpr.h @@ -37,9 +37,9 @@ class CIdentifierExpr : public CExpression { CValue* m_idContext; - STR_String m_identifier; + std::string m_identifier; public: - CIdentifierExpr(const STR_String& identifier,CValue* id_context); + CIdentifierExpr(const std::string& identifier,CValue* id_context); virtual ~CIdentifierExpr(); virtual CValue* Calculate(); diff --git a/source/gameengine/Expressions/EXP_InputParser.h b/source/gameengine/Expressions/EXP_InputParser.h index 80471009a163..f6da0a52371b 100644 --- a/source/gameengine/Expressions/EXP_InputParser.h +++ b/source/gameengine/Expressions/EXP_InputParser.h @@ -31,9 +31,9 @@ class CParser CParser(); virtual ~CParser(); - float GetFloat(STR_String& txt); - CValue* GetValue(STR_String& txt, bool bFallbackToText=false); - CExpression* ProcessText(const char *intext); + float GetFloat(std::string& txt); + CValue* GetValue(std::string& txt, bool bFallbackToText=false); + CExpression* ProcessText(const std::string& intext); void SetContext(CValue* context); private: @@ -84,14 +84,14 @@ class CParser int chcount; // index to character in input string CExpression *errmsg; // contains a errormessage, if scanner error - STR_String text, // contains a copy of the original text + std::string text, // contains a copy of the original text const_as_string; // string representation of the symbol, if symbol is a constant bool boolvalue; // value of the boolean, if symbol is a constant of type boolean CValue* m_identifierContext;// context in which identifiers are looked up - void ScanError(const char *str); - CExpression* Error(const char *str); + void ScanError(const std::string& str); + CExpression* Error(const std::string& str); void NextCh(); void TermChar(char c); void DigRep(); @@ -102,7 +102,7 @@ class CParser #if 0 /* not used yet */ int MakeInt(); #endif - const char *Symbol2Str(int s); + const std::string Symbol2Str(int s); void Term(int s); int Priority(int optor); CExpression *Ex(int i); diff --git a/source/gameengine/Expressions/EXP_IntValue.h b/source/gameengine/Expressions/EXP_IntValue.h index 1dd6ee20dff3..159dd35fb724 100644 --- a/source/gameengine/Expressions/EXP_IntValue.h +++ b/source/gameengine/Expressions/EXP_IntValue.h @@ -29,7 +29,7 @@ class CIntValue : public CPropValue //PLUGIN_DECLARE_SERIAL (CIntValue,CValue) public: - virtual const STR_String GetText(); + virtual const std::string GetText(); virtual double GetNumber(); virtual int GetValueType(); @@ -37,7 +37,7 @@ class CIntValue : public CPropValue CIntValue(); CIntValue(cInt innie); CIntValue(cInt innie, - const char *name, + const std::string& name, AllocationTYPE alloctype=CValue::HEAPVALUE); virtual CValue* Calc(VALUE_OPERATOR op, @@ -63,7 +63,6 @@ class CIntValue : public CPropValue private: cInt m_int; - #ifdef WITH_CXX_GUARDEDALLOC MEM_CXX_CLASS_ALLOC_FUNCS("GE:CIntValue") #endif diff --git a/source/gameengine/Expressions/EXP_ListValue.h b/source/gameengine/Expressions/EXP_ListValue.h index 7f2a9060a6ba..3dbd2f872a08 100644 --- a/source/gameengine/Expressions/EXP_ListValue.h +++ b/source/gameengine/Expressions/EXP_ListValue.h @@ -72,8 +72,7 @@ class CListValue : public CPropValue void SetReleaseOnDestruct(bool bReleaseContents); bool SearchValue(CValue* val); - CValue* FindValue(const STR_String & name); - CValue* FindValue(const char *name); + CValue* FindValue(const std::string& name); void ReleaseAndRemoveAll(); virtual void SetModified(bool bModified); @@ -87,7 +86,7 @@ class CListValue : public CPropValue int GetCount() { return m_pValueArray.size(); } baseIterator GetBegin(); baseIterator GetEnd(); - virtual const STR_String GetText(); + virtual const std::string GetText(); bool CheckEqual(CValue* first,CValue* second); diff --git a/source/gameengine/Expressions/EXP_ListWrapper.h b/source/gameengine/Expressions/EXP_ListWrapper.h index 9d846b4e675b..ac20cd353084 100644 --- a/source/gameengine/Expressions/EXP_ListWrapper.h +++ b/source/gameengine/Expressions/EXP_ListWrapper.h @@ -54,7 +54,7 @@ class CListWrapper : public CValue PyObject *(*m_getItem)(void *, int); /// Returns name item for the giving index, used for python operator list["name"]. - const char *(*m_getItemName)(void *, int); + const std::string (*m_getItemName)(void *, int); /// Sets the nex item to the index place, return false when failed item conversion. bool (*m_setItem)(void *, int, PyObject *); @@ -74,7 +74,7 @@ class CListWrapper : public CValue bool (*checkValid)(void *), int (*getSize)(void *), PyObject *(*getItem)(void *, int), - const char *(*getItemName)(void *, int), + const std::string (*getItemName)(void *, int), bool (*setItem)(void *, int, PyObject *), int flag = FLAG_NONE); ~CListWrapper(); @@ -83,14 +83,14 @@ class CListWrapper : public CValue bool CheckValid(); int GetSize(); PyObject *GetItem(int index); - const char *GetItemName(int index); + const std::string GetItemName(int index); bool SetItem(int index, PyObject *item); bool AllowSetItem(); bool AllowGetItemByName(); bool AllowFindValue(); /// \section CValue Inherited Functions. - virtual STR_String GetName(); + virtual std::string GetName(); virtual int GetValueType(); virtual PyObject *py_repr(); diff --git a/source/gameengine/Expressions/EXP_PyObjectPlus.h b/source/gameengine/Expressions/EXP_PyObjectPlus.h index 774c35575510..dfcdf81614b5 100644 --- a/source/gameengine/Expressions/EXP_PyObjectPlus.h +++ b/source/gameengine/Expressions/EXP_PyObjectPlus.h @@ -41,7 +41,7 @@ #endif #include "EXP_Python.h" -#include "STR_String.h" +#include #include "MT_Vector3.h" #include @@ -357,7 +357,7 @@ typedef int (*KX_PYATTRIBUTE_SET_FUNCTION)(void *self, const struct KX_PYATTRIBU typedef PyObject *(*KX_PYATTRIBUTE_GET_FUNCTION)(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); typedef struct KX_PYATTRIBUTE_DEF { - const char *m_name; // name of the python attribute + const std::string m_name; // name of the python attribute KX_PYATTRIBUTE_TYPE m_type; // type of value KX_PYATTRIBUTE_ACCESS m_access; // read/write access or read-only int m_imin; // minimum value in case of integer attributes @@ -383,12 +383,15 @@ typedef struct KX_PYATTRIBUTE_DEF { short int *m_shortPtr; int *m_intPtr; float *m_floatPtr; - STR_String *m_stringPtr; + std::string *m_stringPtr; MT_Vector3 *m_vectorPtr; char *m_charPtr; } m_typeCheck; } PyAttributeDef; +#define KX_PYATTRIBUTE_NULL \ + {"", KX_PYATTRIBUTE_TYPE_BOOL, KX_PYATTRIBUTE_RW, 0, 1, 0.f, 0.f, false, false, 0, 0, 1, NULL, NULL, NULL, {NULL, NULL, NULL, NULL, NULL, NULL, NULL} } + #define KX_PYATTRIBUTE_BOOL_RW(name, object, field) \ { name, KX_PYATTRIBUTE_TYPE_BOOL, KX_PYATTRIBUTE_RW, 0, 1, 0.f, 0.f, false, false, offsetof(object, field), 0, 1, NULL, NULL, NULL, {&((object *)0)->field, NULL, NULL, NULL, NULL, NULL, NULL} } #define KX_PYATTRIBUTE_BOOL_RW_CHECK(name, object, field, function) \ @@ -490,7 +493,7 @@ typedef struct KX_PYATTRIBUTE_DEF { #define KX_PYATTRIBUTE_FLOAT_MATRIX_RO(name, object, field, length) \ { name, KX_PYATTRIBUTE_TYPE_FLOAT, KX_PYATTRIBUTE_RO, length, length, 0.f, 0.f, false, false, offsetof(object, field), sizeof(((object *)0)->field), 1, NULL, NULL, NULL, {NULL, NULL, NULL, ((object *)0)->field[0], NULL, NULL, NULL} } -// only for STR_String member +// only for std::string member #define KX_PYATTRIBUTE_STRING_RW(name, min, max, clamp, object, field) \ { name, KX_PYATTRIBUTE_TYPE_STRING, KX_PYATTRIBUTE_RW, min, max, 0.f, 0.f, clamp, false, offsetof(object, field), 0, 1, NULL, NULL, NULL, {NULL, NULL, NULL, NULL, &((object *)0)->field, NULL, NULL} } #define KX_PYATTRIBUTE_STRING_RW_CHECK(name, min, max, clamp, object, field, function) \ @@ -609,7 +612,7 @@ class PyObjectPlus /** enable/disable display of deprecation warnings */ static void SetDeprecationWarnings(bool ignoreDeprecationWarnings); /** Shows a deprecation warning */ - static void ShowDeprecationWarning_func(const char *method, const char *prop); + static void ShowDeprecationWarning_func(const std::string& old_way, const std::string& new_way); static void ClearDeprecationWarning(); #endif @@ -625,7 +628,7 @@ class PyObjectPlus }; #ifdef WITH_PYTHON -PyObject *PyUnicode_From_STR_String(const STR_String& str); +PyObject *PyUnicode_FromStdString(const std::string& str); inline PyObject *_bge_proxy_from_ref_borrow(void *self_v) { diff --git a/source/gameengine/Expressions/EXP_StringValue.h b/source/gameengine/Expressions/EXP_StringValue.h index 5e8d77be4640..4db07e95ee8d 100644 --- a/source/gameengine/Expressions/EXP_StringValue.h +++ b/source/gameengine/Expressions/EXP_StringValue.h @@ -29,12 +29,12 @@ class CStringValue : public CPropValue public: /// Construction / destruction CStringValue(); - CStringValue(const char *txt, const char *name, AllocationTYPE alloctype = CValue::HEAPVALUE); + CStringValue(const std::string& txt, const std::string& name, AllocationTYPE alloctype = CValue::HEAPVALUE); virtual ~CStringValue() {} /// CValue implementation - virtual bool IsEqual(const STR_String & other); - virtual const STR_String GetText(); + virtual bool IsEqual(const std::string & other); + virtual const std::string GetText(); virtual double GetNumber(); virtual int GetValueType(); @@ -44,13 +44,13 @@ class CStringValue : public CPropValue virtual CValue* GetReplica(); #ifdef WITH_PYTHON virtual PyObject* ConvertValueToPython() { - return PyUnicode_From_STR_String(m_strString); + return PyUnicode_FromStdString(m_strString); } #endif /* WITH_PYTHON */ private: // data member - STR_String m_strString; + std::string m_strString; #ifdef WITH_CXX_GUARDEDALLOC diff --git a/source/gameengine/Expressions/EXP_Value.h b/source/gameengine/Expressions/EXP_Value.h index 0e13f9649382..8359fbe11830 100644 --- a/source/gameengine/Expressions/EXP_Value.h +++ b/source/gameengine/Expressions/EXP_Value.h @@ -24,7 +24,8 @@ #endif #include // array functionality for the propertylist -#include "STR_String.h" // STR_String class +#include +#include // std::string class #ifdef WITH_CXX_GUARDEDALLOC #include "MEM_guardedalloc.h" @@ -209,7 +210,7 @@ Py_Header //static PyObject *PyMake(PyObject *, PyObject *); virtual PyObject *py_repr(void) { - return PyUnicode_From_STR_String(GetText()); + return PyUnicode_FromStdString(GetText()); } virtual PyObject *ConvertValueToPython() { @@ -283,14 +284,12 @@ Py_Header /// Property Management - virtual void SetProperty(const STR_String& name,CValue* ioProperty); // Set property , overwrites and releases a previous property with the same name if needed - virtual void SetProperty(const char* name,CValue* ioProperty); - virtual CValue* GetProperty(const char* inName); // Get pointer to a property with name , returns NULL if there is no property named - virtual CValue* GetProperty(const STR_String & inName); - const STR_String GetPropertyText(const STR_String & inName); // Get text description of property with name , returns an empty string if there is no property named - float GetPropertyNumber(const STR_String& inName,float defnumber); - virtual bool RemoveProperty(const char *inName); // Remove the property named , returns true if the property was succesfully removed, false if property was not found or could not be removed - virtual std::vector GetPropertyNames(); + virtual void SetProperty(const std::string& name,CValue* ioProperty); // Set property , overwrites and releases a previous property with the same name if needed + virtual CValue* GetProperty(const std::string & inName); + const std::string GetPropertyText(const std::string & inName); // Get text description of property with name , returns an empty string if there is no property named + float GetPropertyNumber(const std::string& inName,float defnumber); + virtual bool RemoveProperty(const std::string& inName); // Remove the property named , returns true if the property was succesfully removed, false if property was not found or could not be removed + virtual std::vector GetPropertyNames(); virtual void ClearProperties(); // Clear all properties virtual void SetPropertiesModified(bool inModified); // Set all properties' modified flag to @@ -299,20 +298,20 @@ Py_Header virtual CValue* GetProperty(int inIndex); // Get property number virtual int GetPropertyCount(); // Get the amount of properties assiocated with this value - virtual CValue* FindIdentifier(const STR_String& identifiername); + virtual CValue* FindIdentifier(const std::string& identifiername); /** Set the wireframe color of this value depending on the CSG * operator type * \attention: not implemented */ virtual void SetColorOperator(VALUE_OPERATOR op); - virtual const STR_String GetText(); + virtual const std::string GetText(); virtual double GetNumber(); virtual int GetValueType(); // Get Prop value type double* ZeroVector() { return m_sZeroVec; } virtual double* GetVector3(bool bGetTransformedVec = false); - virtual STR_String GetName() = 0; // Retrieve the name of the value - virtual void SetName(const char *name); // Set the name of the value + virtual std::string GetName() = 0; // Retrieve the name of the value + virtual void SetName(const std::string& name); // Set the name of the value /** Sets the value to this cvalue. * \attention this particular function should never be called. Why not abstract? */ virtual void SetValue(CValue* newval); @@ -320,7 +319,7 @@ Py_Header virtual void ProcessReplica(); //virtual CValue* Copy() = 0; - STR_String op2str(VALUE_OPERATOR op); + std::string op2str(VALUE_OPERATOR op); // setting / getting flags inline void SetSelected(bool bSelected) { m_ValFlags.Selected = bSelected; } @@ -350,7 +349,7 @@ Py_Header virtual ~CValue(); private: // Member variables - std::map* m_pNamedPropertyArray; // Properties for user/game etc + std::map* m_pNamedPropertyArray; // Properties for user/game etc ValueFlags m_ValFlags; // Frequently used flags in a bitfield (low memoryusage) int m_refcount; // Reference Counter static double m_sZeroVec[3]; @@ -410,19 +409,19 @@ class CPropValue : public CValue { } - virtual void SetName(const char *name) { + virtual void SetName(const std::string& name) { m_strNewName = name; } - virtual STR_String GetName() { - //STR_String namefromprop = GetPropertyText("Name"); - //if (namefromprop.Length() > 0) + virtual std::string GetName() { + //std::string namefromprop = GetPropertyText("Name"); + //if (namefromprop.size() > 0) // return namefromprop; return m_strNewName; } // name of Value protected: - STR_String m_strNewName; // Identification + std::string m_strNewName; // Identification #ifdef WITH_CXX_GUARDEDALLOC MEM_CXX_CLASS_ALLOC_FUNCS("GE:CPropValue") diff --git a/source/gameengine/Expressions/EXP_VoidValue.h b/source/gameengine/Expressions/EXP_VoidValue.h index 0a028838bb71..ef0b0e8c1b84 100644 --- a/source/gameengine/Expressions/EXP_VoidValue.h +++ b/source/gameengine/Expressions/EXP_VoidValue.h @@ -57,7 +57,7 @@ class CVoidValue : public CPropValue virtual ~CVoidValue(); /* Destruct void value, delete memory if we're owning it */ /// Value -> String or number - virtual const STR_String GetText(); /* Get string description of void value (unimplemented) */ + virtual const std::string GetText(); /* Get string description of void value (unimplemented) */ virtual double GetNumber() { return -1; } virtual int GetValueType() { return VALUE_VOID_TYPE; } diff --git a/source/gameengine/Expressions/intern/BoolValue.cpp b/source/gameengine/Expressions/intern/BoolValue.cpp index 1eb33ba38c38..9894d28dd8dc 100644 --- a/source/gameengine/Expressions/intern/BoolValue.cpp +++ b/source/gameengine/Expressions/intern/BoolValue.cpp @@ -25,8 +25,8 @@ // Construction/Destruction ////////////////////////////////////////////////////////////////////// -const STR_String CBoolValue::sTrueString = "TRUE"; -const STR_String CBoolValue::sFalseString = "FALSE"; +const std::string CBoolValue::sTrueString = "TRUE"; +const std::string CBoolValue::sFalseString = "FALSE"; CBoolValue::CBoolValue() /* @@ -46,7 +46,7 @@ CBoolValue::CBoolValue(bool inBool) -CBoolValue::CBoolValue(bool innie,const char *name,AllocationTYPE alloctype) +CBoolValue::CBoolValue(bool innie,const std::string& name,AllocationTYPE alloctype) { m_bool = innie; SetName(name); @@ -193,7 +193,7 @@ int CBoolValue::GetValueType() -const STR_String CBoolValue::GetText() +const std::string CBoolValue::GetText() { return m_bool ? sTrueString : sFalseString; } diff --git a/source/gameengine/Expressions/intern/EmptyValue.cpp b/source/gameengine/Expressions/intern/EmptyValue.cpp index 539367dad5eb..7fb6a86f9182 100644 --- a/source/gameengine/Expressions/intern/EmptyValue.cpp +++ b/source/gameengine/Expressions/intern/EmptyValue.cpp @@ -114,7 +114,7 @@ double* CEmptyValue::GetVector3(bool bGetTransformedVec) -const STR_String CEmptyValue::GetText() +const std::string CEmptyValue::GetText() { return ""; } diff --git a/source/gameengine/Expressions/intern/ErrorValue.cpp b/source/gameengine/Expressions/intern/ErrorValue.cpp index 2a543c0dbb17..2cc6ddb28829 100644 --- a/source/gameengine/Expressions/intern/ErrorValue.cpp +++ b/source/gameengine/Expressions/intern/ErrorValue.cpp @@ -33,7 +33,7 @@ effect: constructs a new CErrorValue containing errormessage "Error" -CErrorValue::CErrorValue(const char *errmsg) +CErrorValue::CErrorValue(const std::string& errmsg) /* pre: effect: constructs a new CErrorValue containing errormessage errmsg @@ -105,7 +105,7 @@ int CErrorValue::GetValueType() -const STR_String CErrorValue::GetText() +const std::string CErrorValue::GetText() { return m_strErrorText; } diff --git a/source/gameengine/Expressions/intern/FloatValue.cpp b/source/gameengine/Expressions/intern/FloatValue.cpp index 6494ccdaeee4..d2165eb87ba0 100644 --- a/source/gameengine/Expressions/intern/FloatValue.cpp +++ b/source/gameengine/Expressions/intern/FloatValue.cpp @@ -22,6 +22,8 @@ #include "EXP_ErrorValue.h" #include "EXP_VoidValue.h" +#include + ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// @@ -47,7 +49,7 @@ effect: constructs a new CFloatValue containing value fl -CFloatValue::CFloatValue(float fl,const char *name,AllocationTYPE alloctype) +CFloatValue::CFloatValue(float fl,const std::string& name,AllocationTYPE alloctype) /* pre: effect: constructs a new CFloatValue containing value fl @@ -295,9 +297,9 @@ void CFloatValue::SetValue(CValue* newval) -const STR_String CFloatValue::GetText() +const std::string CFloatValue::GetText() { - return STR_String().Format("%f",m_float); + return std::to_string(m_float); } diff --git a/source/gameengine/Expressions/intern/IdentifierExpr.cpp b/source/gameengine/Expressions/intern/IdentifierExpr.cpp index 8fbbf41cd63e..82260fd1b881 100644 --- a/source/gameengine/Expressions/intern/IdentifierExpr.cpp +++ b/source/gameengine/Expressions/intern/IdentifierExpr.cpp @@ -32,7 +32,7 @@ #include "EXP_IdentifierExpr.h" -CIdentifierExpr::CIdentifierExpr(const STR_String& identifier,CValue* id_context) +CIdentifierExpr::CIdentifierExpr(const std::string& identifier,CValue* id_context) :m_identifier(identifier) { if (id_context) diff --git a/source/gameengine/Expressions/intern/IfExpr.cpp b/source/gameengine/Expressions/intern/IfExpr.cpp index d7771e3b7e87..9efcf6f181c7 100644 --- a/source/gameengine/Expressions/intern/IfExpr.cpp +++ b/source/gameengine/Expressions/intern/IfExpr.cpp @@ -72,7 +72,7 @@ CValue* CIfExpr::Calculate() { CValue *guardval; guardval = m_guard->Calculate(); - const STR_String& text = guardval->GetText(); + const std::string& text = guardval->GetText(); guardval->Release(); if (text == CBoolValue::sTrueString) diff --git a/source/gameengine/Expressions/intern/InputParser.cpp b/source/gameengine/Expressions/intern/InputParser.cpp index a787276f0aef..943e9659d34f 100644 --- a/source/gameengine/Expressions/intern/InputParser.cpp +++ b/source/gameengine/Expressions/intern/InputParser.cpp @@ -32,6 +32,9 @@ #include "EXP_Operator1Expr.h" #include "EXP_IdentifierExpr.h" +#include +#include + // this is disable at the moment, I expected a memleak from it, but the error-cleanup was the reason // well, looks we don't need it anyway, until maybe the Curved Surfaces are integrated into CSG // cool things like (IF(LOD==1,CCurvedValue,IF(LOD==2,CCurvedValue2)) etc... @@ -65,7 +68,7 @@ CParser::~CParser() -void CParser::ScanError(const char *str) +void CParser::ScanError(const std::string& str) { // sets the global variable errmsg to an errormessage with // contents str, appending if it already exists @@ -80,7 +83,7 @@ void CParser::ScanError(const char *str) -CExpression* CParser::Error(const char *str) +CExpression* CParser::Error(const std::string& str) { // makes and returns a new CConstExpr filled with an CErrorValue // with string str @@ -96,7 +99,7 @@ void CParser::NextCh() // and increases the global variable chcount chcount++; - if (chcount < text.Length()) + if (chcount < text.size()) ch = text[chcount]; else ch = 0x00; @@ -114,8 +117,7 @@ void CParser::TermChar(char c) } else { - STR_String str; - str.Format("Warning: %c expected\ncontinuing without it", c); + std::string str = (boost::format("Warning: %c expected\ncontinuing without it") % c).str(); trace(str); } } @@ -149,7 +151,7 @@ void CParser::GrabString(int start) { // puts part of the input string into the global variable // const_as_string, from position start, to position chchount - const_as_string = text.Mid(start, chcount-start); + const_as_string = text.substr(start, chcount - start); } @@ -163,7 +165,7 @@ void CParser::GrabRealString(int start) int i; char tmpch; - const_as_string = STR_String(); + const_as_string = std::string(); for (i=start;iCalculate(); @@ -567,8 +567,8 @@ CExpression *CParser::Expr() return Ex(1); } -CExpression* CParser::ProcessText -(const char *intext) { +CExpression* CParser::ProcessText(const std::string& intext) +{ // and parses the string in intext and returns it. @@ -578,7 +578,7 @@ CExpression* CParser::ProcessText chcount = 0; - if (text.Length() == 0) { + if (text.size() == 0) { return NULL; } @@ -595,7 +595,7 @@ CExpression* CParser::ProcessText if (sym != eolsym) { CExpression* oldexpr = expr; expr = new COperator2Expr(VALUE_ADD_OPERATOR, - oldexpr, Error(STR_String("Extra characters after expression")));//new CConstExpr(new CErrorValue("Extra characters after expression"))); + oldexpr, Error("Extra characters after expression"));//new CConstExpr(new CErrorValue("Extra characters after expression"))); } if (errmsg) errmsg->Release(); @@ -605,7 +605,7 @@ CExpression* CParser::ProcessText -float CParser::GetFloat(STR_String& txt) +float CParser::GetFloat(std::string& txt) { // returns parsed text into a float // empty string returns -1 @@ -630,7 +630,7 @@ float CParser::GetFloat(STR_String& txt) return result; } -CValue* CParser::GetValue(STR_String& txt, bool bFallbackToText) +CValue* CParser::GetValue(std::string& txt, bool bFallbackToText) { // returns parsed text into a value, // empty string returns NULL value ! @@ -649,7 +649,7 @@ CValue* CParser::GetValue(STR_String& txt, bool bFallbackToText) result->Release(); result=NULL; if (bFallbackToText) { - if (txt.Length()>0) + if (txt.size()>0) { result = new CStringValue(txt,""); } diff --git a/source/gameengine/Expressions/intern/IntValue.cpp b/source/gameengine/Expressions/intern/IntValue.cpp index 08d204392e17..4dfc56d810dc 100644 --- a/source/gameengine/Expressions/intern/IntValue.cpp +++ b/source/gameengine/Expressions/intern/IntValue.cpp @@ -24,6 +24,8 @@ #include "CM_Message.h" +#include + ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// @@ -53,7 +55,7 @@ effect: constructs a new CIntValue containing cInt innie -CIntValue::CIntValue(cInt innie,const char *name,AllocationTYPE alloctype) +CIntValue::CIntValue(cInt innie,const std::string& name,AllocationTYPE alloctype) { m_int = innie; SetName(name); @@ -301,9 +303,9 @@ int CIntValue::GetValueType() -const STR_String CIntValue::GetText() +const std::string CIntValue::GetText() { - return STR_String().Format("%lld",m_int); + return (boost::format("%lld") % m_int).str(); } diff --git a/source/gameengine/Expressions/intern/ListValue.cpp b/source/gameengine/Expressions/intern/ListValue.cpp index 2f242c516eaa..7197f26feb04 100644 --- a/source/gameengine/Expressions/intern/ListValue.cpp +++ b/source/gameengine/Expressions/intern/ListValue.cpp @@ -51,22 +51,20 @@ CListValue::~CListValue() } -static STR_String gstrListRep=STR_String("List"); - -const STR_String CListValue::GetText() +const std::string CListValue::GetText() { - gstrListRep = "["; - STR_String commastr = ""; + std::string strListRep = "["; + std::string commastr = ""; for (int i=0;iGetText(); + strListRep += commastr; + strListRep += GetValue(i)->GetText(); commastr = ","; } - gstrListRep += "]"; + strListRep += "]"; - return gstrListRep; + return strListRep; } @@ -141,16 +139,7 @@ void CListValue::ReleaseAndRemoveAll() -CValue* CListValue::FindValue(const STR_String &name) -{ - for (int i=0; i < GetCount(); i++) - if (GetValue(i)->GetName() == name) - return GetValue(i); - - return NULL; -} - -CValue* CListValue::FindValue(const char *name) +CValue* CListValue::FindValue(const std::string &name) { for (int i=0; i < GetCount(); i++) if (GetValue(i)->GetName() == name) @@ -214,7 +203,7 @@ bool CListValue::CheckEqual(CValue* first,CValue* second) if (eqval==NULL) return false; - const STR_String& text = eqval->GetText(); + const std::string& text = eqval->GetText(); if (text == CBoolValue::sTrueString) { result = true; @@ -472,7 +461,7 @@ static int listvalue_buffer_contains(PyObject *self_v, PyObject *value) } if (PyUnicode_Check(value)) { - if (self->FindValue((const char *)_PyUnicode_AsString(value))) { + if (self->FindValue(_PyUnicode_AsString(value))) { return 1; } } @@ -561,7 +550,7 @@ PyMethodDef CListValue::Methods[] = { }; PyAttributeDef CListValue::Attributes[] = { - { NULL } //Sentinel + KX_PYATTRIBUTE_NULL //Sentinel }; PyObject *CListValue::Pyappend(PyObject *value) @@ -657,7 +646,7 @@ PyObject *CListValue::Pyget(PyObject *args) if (!PyArg_ParseTuple(args, "s|O:get", &key, &def)) return NULL; - CValue *item = FindValue((const char *)key); + CValue *item = FindValue(key); if (item) { PyObject *pyobj = item->ConvertValueToPython(); if (pyobj) diff --git a/source/gameengine/Expressions/intern/ListWrapper.cpp b/source/gameengine/Expressions/intern/ListWrapper.cpp index 6d76d25268af..4db011a38655 100644 --- a/source/gameengine/Expressions/intern/ListWrapper.cpp +++ b/source/gameengine/Expressions/intern/ListWrapper.cpp @@ -33,7 +33,7 @@ CListWrapper::CListWrapper(void *client, bool (*checkValid)(void *), int (*getSize)(void *), PyObject *(*getItem)(void *, int), - const char *(*getItemName)(void *, int), + const std::string (*getItemName)(void *, int), bool (*setItem)(void *, int, PyObject *), int flag) :m_client(client), @@ -80,7 +80,7 @@ PyObject *CListWrapper::GetItem(int index) return (*m_getItem)(m_client, index); } -const char *CListWrapper::GetItemName(int index) +const std::string CListWrapper::GetItemName(int index) { return (*m_getItemName)(m_client, index); } @@ -107,7 +107,7 @@ bool CListWrapper::AllowFindValue() // ================================================================ -STR_String CListWrapper::GetName() +std::string CListWrapper::GetName() { return "ListWrapper"; } @@ -228,7 +228,7 @@ PyObject *CListWrapper::py_mapping_subscript(PyObject *self, PyObject *key) int size = list->GetSize(); for (unsigned int i = 0; i < size; ++i) { - if (strcmp(list->GetItemName(i), name) == 0) { + if (list->GetItemName(i) == name) { return list->GetItem(i); } } @@ -269,7 +269,7 @@ int CListWrapper::py_mapping_ass_subscript(PyObject *self, PyObject *key, PyObje int size = list->GetSize(); for (unsigned int i = 0; i < size; ++i) { - if (strcmp(list->GetItemName(i), name) == 0) { + if (list->GetItemName(i) == name) { if (!list->SetItem(i, value)) { return -1; } @@ -303,7 +303,7 @@ int CListWrapper::py_contains(PyObject *self, PyObject *key) const char *name = _PyUnicode_AsString(key); for (unsigned int i = 0, size = list->GetSize(); i < size; ++i) { - if (strcmp(list->GetItemName(i), name) == 0) { + if (list->GetItemName(i) == name) { return 1; } } @@ -375,7 +375,7 @@ PyMethodDef CListWrapper::Methods[] = { }; PyAttributeDef CListWrapper::Attributes[] = { - {NULL} //Sentinel + KX_PYATTRIBUTE_NULL //Sentinel }; /* Matches python dict.get(key, [default]) */ @@ -400,7 +400,7 @@ PyObject *CListWrapper::PyGet(PyObject *args) } for (unsigned int i = 0; i < GetSize(); ++i) { - if (strcmp(GetItemName(i), name) == 0) { + if (GetItemName(i) == name) { return GetItem(i); } } diff --git a/source/gameengine/Expressions/intern/PyObjectPlus.cpp b/source/gameengine/Expressions/intern/PyObjectPlus.cpp index 310e69bd8a7b..23acc398eb98 100644 --- a/source/gameengine/Expressions/intern/PyObjectPlus.cpp +++ b/source/gameengine/Expressions/intern/PyObjectPlus.cpp @@ -46,7 +46,7 @@ * ----------------------------- */ #include "EXP_PyObjectPlus.h" -#include "STR_String.h" +#include #include "MT_Vector3.h" #include "MEM_guardedalloc.h" @@ -276,7 +276,7 @@ PyMethodDef PyObjectPlus::Methods[] = { #define BGE_PY_ATTR_INVALID (&(PyObjectPlus::Attributes[0])) PyAttributeDef PyObjectPlus::Attributes[] = { KX_PYATTRIBUTE_RO_FUNCTION("invalid", PyObjectPlus, pyattr_get_invalid), - {NULL} //Sentinel + KX_PYATTRIBUTE_NULL //Sentinel }; @@ -481,8 +481,8 @@ PyObject *PyObjectPlus::py_get_attrdef(PyObject *self_py, const PyAttributeDef * } case KX_PYATTRIBUTE_TYPE_STRING: { - STR_String *val = reinterpret_cast(ptr); - return PyUnicode_From_STR_String(*val); + std::string *val = reinterpret_cast(ptr); + return PyUnicode_FromStdString(*val); } case KX_PYATTRIBUTE_TYPE_CHAR: { @@ -500,7 +500,7 @@ static bool py_check_attr_float(float *var, PyObject *value, const PyAttributeDe float val = PyFloat_AsDouble(value); if (val == -1.0f && PyErr_Occurred()) { - PyErr_Format(PyExc_TypeError, "expected float value for attribute \"%s\"", attrdef->m_name); + PyErr_Format(PyExc_TypeError, "expected float value for attribute \"%s\"", attrdef->m_name.c_str()); return false; } if (attrdef->m_clamp) @@ -512,7 +512,7 @@ static bool py_check_attr_float(float *var, PyObject *value, const PyAttributeDe } else if (val < attrdef->m_fmin || val > attrdef->m_fmax) { - PyErr_Format(PyExc_ValueError, "value out of range for attribute \"%s\"", attrdef->m_name); + PyErr_Format(PyExc_ValueError, "value out of range for attribute \"%s\"", attrdef->m_name.c_str()); return false; } *var = (float)val; @@ -540,12 +540,12 @@ int PyObjectPlus::py_set_attrdef(PyObject *self_py, PyObject *value, const PyAtt { if (!PySequence_Check(value)) { - PyErr_Format(PyExc_TypeError, "expected a sequence for attribute \"%s\"", attrdef->m_name); + PyErr_Format(PyExc_TypeError, "expected a sequence for attribute \"%s\"", attrdef->m_name.c_str()); return PY_SET_ATTR_FAIL; } if (PySequence_Size(value) != attrdef->m_length) { - PyErr_Format(PyExc_TypeError, "incorrect number of elements in sequence for attribute \"%s\"", attrdef->m_name); + PyErr_Format(PyExc_TypeError, "incorrect number of elements in sequence for attribute \"%s\"", attrdef->m_name.c_str()); return PY_SET_ATTR_FAIL; } switch (attrdef->m_type) @@ -553,7 +553,7 @@ int PyObjectPlus::py_set_attrdef(PyObject *self_py, PyObject *value, const PyAtt case KX_PYATTRIBUTE_TYPE_FUNCTION: if (attrdef->m_setFunction == NULL) { - PyErr_Format(PyExc_AttributeError, "function attribute without function for attribute \"%s\", report to blender.org", attrdef->m_name); + PyErr_Format(PyExc_AttributeError, "function attribute without function for attribute \"%s\", report to blender.org", attrdef->m_name.c_str()); return PY_SET_ATTR_FAIL; } return (*attrdef->m_setFunction)(ref, attrdef, value); @@ -572,7 +572,7 @@ int PyObjectPlus::py_set_attrdef(PyObject *self_py, PyObject *value, const PyAtt break; default: // should not happen - PyErr_Format(PyExc_AttributeError, "Unsupported attribute type for attribute \"%s\", report to blender.org", attrdef->m_name); + PyErr_Format(PyExc_AttributeError, "Unsupported attribute type for attribute \"%s\", report to blender.org", attrdef->m_name.c_str()); return PY_SET_ATTR_FAIL; } // let's implement a smart undo method @@ -602,7 +602,7 @@ int PyObjectPlus::py_set_attrdef(PyObject *self_py, PyObject *value, const PyAtt } else { - PyErr_Format(PyExc_TypeError, "expected an integer or a bool for attribute \"%s\"", attrdef->m_name); + PyErr_Format(PyExc_TypeError, "expected an integer or a bool for attribute \"%s\"", attrdef->m_name.c_str()); goto UNDO_AND_ERROR; } break; @@ -623,14 +623,14 @@ int PyObjectPlus::py_set_attrdef(PyObject *self_py, PyObject *value, const PyAtt } else if (val < attrdef->m_imin || val > attrdef->m_imax) { - PyErr_Format(PyExc_ValueError, "item value out of range for attribute \"%s\"", attrdef->m_name); + PyErr_Format(PyExc_ValueError, "item value out of range for attribute \"%s\"", attrdef->m_name.c_str()); goto UNDO_AND_ERROR; } *var = (short int)val; } else { - PyErr_Format(PyExc_TypeError, "expected an integer for attribute \"%s\"", attrdef->m_name); + PyErr_Format(PyExc_TypeError, "expected an integer for attribute \"%s\"", attrdef->m_name.c_str()); goto UNDO_AND_ERROR; } break; @@ -639,7 +639,7 @@ int PyObjectPlus::py_set_attrdef(PyObject *self_py, PyObject *value, const PyAtt // enum are equivalent to int, just make sure that the field size matches: if (sizeof(int) != attrdef->m_size) { - PyErr_Format(PyExc_AttributeError, "Size check error for attribute, \"%s\", report to blender.org", attrdef->m_name); + PyErr_Format(PyExc_AttributeError, "Size check error for attribute, \"%s\", report to blender.org", attrdef->m_name.c_str()); goto UNDO_AND_ERROR; } // walkthrough @@ -659,14 +659,14 @@ int PyObjectPlus::py_set_attrdef(PyObject *self_py, PyObject *value, const PyAtt } else if (val < attrdef->m_imin || val > attrdef->m_imax) { - PyErr_Format(PyExc_ValueError, "item value out of range for attribute \"%s\"", attrdef->m_name); + PyErr_Format(PyExc_ValueError, "item value out of range for attribute \"%s\"", attrdef->m_name.c_str()); goto UNDO_AND_ERROR; } *var = (int)val; } else { - PyErr_Format(PyExc_TypeError, "expected an integer for attribute \"%s\"", attrdef->m_name); + PyErr_Format(PyExc_TypeError, "expected an integer for attribute \"%s\"", attrdef->m_name.c_str()); goto UNDO_AND_ERROR; } break; @@ -678,7 +678,7 @@ int PyObjectPlus::py_set_attrdef(PyObject *self_py, PyObject *value, const PyAtt float val = PyFloat_AsDouble(item); if (val == -1.0f && PyErr_Occurred()) { - PyErr_Format(PyExc_TypeError, "expected a float for attribute \"%s\"", attrdef->m_name); + PyErr_Format(PyExc_TypeError, "expected a float for attribute \"%s\"", attrdef->m_name.c_str()); goto UNDO_AND_ERROR; } else if (attrdef->m_clamp) @@ -690,7 +690,7 @@ int PyObjectPlus::py_set_attrdef(PyObject *self_py, PyObject *value, const PyAtt } else if (val < attrdef->m_fmin || val > attrdef->m_fmax) { - PyErr_Format(PyExc_ValueError, "item value out of range for attribute \"%s\"", attrdef->m_name); + PyErr_Format(PyExc_ValueError, "item value out of range for attribute \"%s\"", attrdef->m_name.c_str()); goto UNDO_AND_ERROR; } *var = (float)val; @@ -698,7 +698,7 @@ int PyObjectPlus::py_set_attrdef(PyObject *self_py, PyObject *value, const PyAtt } default: // should not happen - PyErr_Format(PyExc_AttributeError, "type check error for attribute \"%s\", report to blender.org", attrdef->m_name); + PyErr_Format(PyExc_AttributeError, "type check error for attribute \"%s\", report to blender.org", attrdef->m_name.c_str()); goto UNDO_AND_ERROR; } // finished using item, release @@ -712,7 +712,7 @@ int PyObjectPlus::py_set_attrdef(PyObject *self_py, PyObject *value, const PyAtt { // if the checing function didnt set an error then set a generic one here so we don't set an error with no exception if (PyErr_Occurred()==0) - PyErr_Format(PyExc_AttributeError, "type check error for attribute \"%s\", reasion unknown", attrdef->m_name); + PyErr_Format(PyExc_AttributeError, "type check error for attribute \"%s\", reasion unknown", attrdef->m_name.c_str()); // post check returned an error, restore values UNDO_AND_ERROR: @@ -736,7 +736,7 @@ int PyObjectPlus::py_set_attrdef(PyObject *self_py, PyObject *value, const PyAtt { if (attrdef->m_setFunction == NULL) { - PyErr_Format(PyExc_AttributeError, "function attribute without function \"%s\", report to blender.org", attrdef->m_name); + PyErr_Format(PyExc_AttributeError, "function attribute without function \"%s\", report to blender.org", attrdef->m_name.c_str()); return PY_SET_ATTR_FAIL; } return (*attrdef->m_setFunction)(ref, attrdef, value); @@ -769,7 +769,7 @@ int PyObjectPlus::py_set_attrdef(PyObject *self_py, PyObject *value, const PyAtt bufferSize *= attrdef->m_imin; break; case KX_PYATTRIBUTE_TYPE_STRING: - sourceBuffer = reinterpret_cast(ptr)->Ptr(); + sourceBuffer = (char *)reinterpret_cast(ptr)->c_str(); if (sourceBuffer) bufferSize = strlen(reinterpret_cast(sourceBuffer))+1; break; @@ -777,7 +777,7 @@ int PyObjectPlus::py_set_attrdef(PyObject *self_py, PyObject *value, const PyAtt bufferSize = sizeof(MT_Vector3); break; default: - PyErr_Format(PyExc_AttributeError, "unknown type for attribute \"%s\", report to blender.org", attrdef->m_name); + PyErr_Format(PyExc_AttributeError, "unknown type for attribute \"%s\", report to blender.org", attrdef->m_name.c_str()); return PY_SET_ATTR_FAIL; } if (bufferSize) @@ -805,7 +805,7 @@ int PyObjectPlus::py_set_attrdef(PyObject *self_py, PyObject *value, const PyAtt } else { - PyErr_Format(PyExc_TypeError, "expected an integer or a bool for attribute \"%s\"", attrdef->m_name); + PyErr_Format(PyExc_TypeError, "expected an integer or a bool for attribute \"%s\"", attrdef->m_name.c_str()); goto FREE_AND_ERROR; } break; @@ -823,7 +823,7 @@ int PyObjectPlus::py_set_attrdef(PyObject *self_py, PyObject *value, const PyAtt } else { - PyErr_Format(PyExc_TypeError, "expected an integer or a bool for attribute \"%s\"", attrdef->m_name); + PyErr_Format(PyExc_TypeError, "expected an integer or a bool for attribute \"%s\"", attrdef->m_name.c_str()); goto FREE_AND_ERROR; } if (attrdef->m_imax) @@ -848,7 +848,7 @@ int PyObjectPlus::py_set_attrdef(PyObject *self_py, PyObject *value, const PyAtt break; } default: - PyErr_Format(PyExc_TypeError, "internal error: unsupported flag field \"%s\"", attrdef->m_name); + PyErr_Format(PyExc_TypeError, "internal error: unsupported flag field \"%s\"", attrdef->m_name.c_str()); goto FREE_AND_ERROR; } break; @@ -868,14 +868,14 @@ int PyObjectPlus::py_set_attrdef(PyObject *self_py, PyObject *value, const PyAtt } else if (val < attrdef->m_imin || val > attrdef->m_imax) { - PyErr_Format(PyExc_ValueError, "value out of range for attribute \"%s\"", attrdef->m_name); + PyErr_Format(PyExc_ValueError, "value out of range for attribute \"%s\"", attrdef->m_name.c_str()); goto FREE_AND_ERROR; } *var = (short int)val; } else { - PyErr_Format(PyExc_TypeError, "expected an integer for attribute \"%s\"", attrdef->m_name); + PyErr_Format(PyExc_TypeError, "expected an integer for attribute \"%s\"", attrdef->m_name.c_str()); goto FREE_AND_ERROR; } break; @@ -884,7 +884,7 @@ int PyObjectPlus::py_set_attrdef(PyObject *self_py, PyObject *value, const PyAtt // enum are equivalent to int, just make sure that the field size matches: if (sizeof(int) != attrdef->m_size) { - PyErr_Format(PyExc_AttributeError, "attribute size check error for attribute \"%s\", report to blender.org", attrdef->m_name); + PyErr_Format(PyExc_AttributeError, "attribute size check error for attribute \"%s\", report to blender.org", attrdef->m_name.c_str()); goto FREE_AND_ERROR; } // walkthrough @@ -903,14 +903,14 @@ int PyObjectPlus::py_set_attrdef(PyObject *self_py, PyObject *value, const PyAtt } else if (val < attrdef->m_imin || val > attrdef->m_imax) { - PyErr_Format(PyExc_ValueError, "value out of range for attribute \"%s\"", attrdef->m_name); + PyErr_Format(PyExc_ValueError, "value out of range for attribute \"%s\"", attrdef->m_name.c_str()); goto FREE_AND_ERROR; } *var = (int)val; } else { - PyErr_Format(PyExc_TypeError, "expected an integer for attribute \"%s\"", attrdef->m_name); + PyErr_Format(PyExc_TypeError, "expected an integer for attribute \"%s\"", attrdef->m_name.c_str()); goto FREE_AND_ERROR; } break; @@ -922,12 +922,12 @@ int PyObjectPlus::py_set_attrdef(PyObject *self_py, PyObject *value, const PyAtt { if (attrdef->m_size != attrdef->m_imin*attrdef->m_imax*sizeof(float)) { - PyErr_Format(PyExc_TypeError, "internal error: incorrect field size for attribute \"%s\"", attrdef->m_name); + PyErr_Format(PyExc_TypeError, "internal error: incorrect field size for attribute \"%s\"", attrdef->m_name.c_str()); goto FREE_AND_ERROR; } if (!PySequence_Check(value) || PySequence_Size(value) != attrdef->m_imin) { - PyErr_Format(PyExc_TypeError, "expected a sequence of [%d][%d] floats for attribute \"%s\"", attrdef->m_imin, attrdef->m_imax, attrdef->m_name); + PyErr_Format(PyExc_TypeError, "expected a sequence of [%d][%d] floats for attribute \"%s\"", attrdef->m_imin, attrdef->m_imax, attrdef->m_name.c_str()); goto FREE_AND_ERROR; } for (int i=0; im_imin; i++) @@ -935,7 +935,7 @@ int PyObjectPlus::py_set_attrdef(PyObject *self_py, PyObject *value, const PyAtt PyObject *list = PySequence_GetItem(value, i); /* new ref */ if (!PySequence_Check(list) || PySequence_Size(list) != attrdef->m_imax) { - PyErr_Format(PyExc_TypeError, "expected a sequence of [%d][%d] floats for attribute \"%s\"", attrdef->m_imin, attrdef->m_imax, attrdef->m_name); + PyErr_Format(PyExc_TypeError, "expected a sequence of [%d][%d] floats for attribute \"%s\"", attrdef->m_imin, attrdef->m_imax, attrdef->m_name.c_str()); goto RESTORE_AND_ERROR; } for (int j=0; jm_imax; j++) @@ -943,7 +943,7 @@ int PyObjectPlus::py_set_attrdef(PyObject *self_py, PyObject *value, const PyAtt item = PySequence_GetItem(list, j); /* new ref */ if (!py_check_attr_float(var, item, attrdef)) { - PyErr_Format(PyExc_TypeError, "expected a sequence of [%d][%d] floats for attribute \"%s\"", attrdef->m_imin, attrdef->m_imax, attrdef->m_name); + PyErr_Format(PyExc_TypeError, "expected a sequence of [%d][%d] floats for attribute \"%s\"", attrdef->m_imin, attrdef->m_imax, attrdef->m_name.c_str()); goto RESTORE_AND_ERROR; } Py_DECREF(item); @@ -958,12 +958,12 @@ int PyObjectPlus::py_set_attrdef(PyObject *self_py, PyObject *value, const PyAtt { if (attrdef->m_size != attrdef->m_imax*sizeof(float)) { - PyErr_Format(PyExc_TypeError, "internal error: incorrect field size for attribute \"%s\"", attrdef->m_name); + PyErr_Format(PyExc_TypeError, "internal error: incorrect field size for attribute \"%s\"", attrdef->m_name.c_str()); goto FREE_AND_ERROR; } if (!PySequence_Check(value) || PySequence_Size(value) != attrdef->m_imax) { - PyErr_Format(PyExc_TypeError, "expected a sequence of [%d] floats for attribute \"%s\"", attrdef->m_imax, attrdef->m_name); + PyErr_Format(PyExc_TypeError, "expected a sequence of [%d] floats for attribute \"%s\"", attrdef->m_imax, attrdef->m_name.c_str()); goto FREE_AND_ERROR; } for (int i=0; im_imax; i++) @@ -989,7 +989,7 @@ int PyObjectPlus::py_set_attrdef(PyObject *self_py, PyObject *value, const PyAtt { if (!PySequence_Check(value) || PySequence_Size(value) != 3) { - PyErr_Format(PyExc_TypeError, "expected a sequence of 3 floats for attribute \"%s\"", attrdef->m_name); + PyErr_Format(PyExc_TypeError, "expected a sequence of 3 floats for attribute \"%s\"", attrdef->m_name.c_str()); goto FREE_AND_ERROR; } MT_Vector3 *var = reinterpret_cast(ptr); @@ -1001,7 +1001,7 @@ int PyObjectPlus::py_set_attrdef(PyObject *self_py, PyObject *value, const PyAtt item = NULL; if (val == -1.0f && PyErr_Occurred()) { - PyErr_Format(PyExc_TypeError, "expected a sequence of 3 floats for attribute \"%s\"", attrdef->m_name); + PyErr_Format(PyExc_TypeError, "expected a sequence of 3 floats for attribute \"%s\"", attrdef->m_name.c_str()); goto RESTORE_AND_ERROR; } else if (attrdef->m_clamp) @@ -1013,7 +1013,7 @@ int PyObjectPlus::py_set_attrdef(PyObject *self_py, PyObject *value, const PyAtt } else if (val < attrdef->m_fmin || val > attrdef->m_fmax) { - PyErr_Format(PyExc_ValueError, "value out of range for attribute \"%s\"", attrdef->m_name); + PyErr_Format(PyExc_ValueError, "value out of range for attribute \"%s\"", attrdef->m_name.c_str()); goto RESTORE_AND_ERROR; } (*var)[i] = (MT_Scalar)val; @@ -1031,14 +1031,14 @@ int PyObjectPlus::py_set_attrdef(PyObject *self_py, PyObject *value, const PyAtt } else { - PyErr_Format(PyExc_TypeError, "expected a string for attribute \"%s\"", attrdef->m_name); + PyErr_Format(PyExc_TypeError, "expected a string for attribute \"%s\"", attrdef->m_name.c_str()); goto FREE_AND_ERROR; } break; } case KX_PYATTRIBUTE_TYPE_STRING: { - STR_String *var = reinterpret_cast(ptr); + std::string *var = reinterpret_cast(ptr); if (PyUnicode_Check(value)) { Py_ssize_t val_len; @@ -1048,33 +1048,32 @@ int PyObjectPlus::py_set_attrdef(PyObject *self_py, PyObject *value, const PyAtt if (val_len < attrdef->m_imin) { // can't increase the length of the string - PyErr_Format(PyExc_ValueError, "string length too short for attribute \"%s\"", attrdef->m_name); + PyErr_Format(PyExc_ValueError, "string length too short for attribute \"%s\"", attrdef->m_name.c_str()); goto FREE_AND_ERROR; } else if (val_len > attrdef->m_imax) { // trim the string - var->SetLength(attrdef->m_imax); - memcpy(var->Ptr(), val, attrdef->m_imax - 1); + *var = var->substr(0, attrdef->m_imax); break; } } else if (val_len < attrdef->m_imin || val_len > attrdef->m_imax) { - PyErr_Format(PyExc_ValueError, "string length out of range for attribute \"%s\"", attrdef->m_name); + PyErr_Format(PyExc_ValueError, "string length out of range for attribute \"%s\"", attrdef->m_name.c_str()); goto FREE_AND_ERROR; } *var = val; } else { - PyErr_Format(PyExc_TypeError, "expected a string for attribute \"%s\"", attrdef->m_name); + PyErr_Format(PyExc_TypeError, "expected a string for attribute \"%s\"", attrdef->m_name.c_str()); goto FREE_AND_ERROR; } break; } default: // should not happen - PyErr_Format(PyExc_AttributeError, "unknown type for attribute \"%s\", report to blender.org", attrdef->m_name); + PyErr_Format(PyExc_AttributeError, "unknown type for attribute \"%s\", report to blender.org", attrdef->m_name.c_str()); goto FREE_AND_ERROR; } } @@ -1089,8 +1088,8 @@ int PyObjectPlus::py_set_attrdef(PyObject *self_py, PyObject *value, const PyAtt { if (attrdef->m_type == KX_PYATTRIBUTE_TYPE_STRING) { - // special case for STR_String: restore the string - STR_String *var = reinterpret_cast(ptr); + // special case for std::string: restore the string + std::string *var = reinterpret_cast(ptr); *var = reinterpret_cast(undoBuffer); } else @@ -1181,9 +1180,9 @@ PyObject *PyObjectPlus::NewProxyPlus_Ext(PyObjectPlus *self, PyTypeObject *tp, v return self->m_proxy; } -PyObject *PyUnicode_From_STR_String(const STR_String& str) +PyObject *PyUnicode_FromStdString(const std::string& str) { - return PyUnicode_FromStringAndSize(str.ReadPtr(), str.Length()); + return PyUnicode_FromStringAndSize(str.c_str(), str.size()); } /////////////////////////////////////////////////////////////////////////////////////////////// @@ -1196,7 +1195,7 @@ void PyObjectPlus::SetDeprecationWarnings(bool ignoreDeprecationWarnings) m_ignore_deprecation_warnings = ignoreDeprecationWarnings; } -void PyObjectPlus::ShowDeprecationWarning_func(const char *old_way, const char *new_way) +void PyObjectPlus::ShowDeprecationWarning_func(const std::string& old_way, const std::string& new_way) { CM_PythonWarning("method " << old_way << " is deprecated, please use " << new_way << " instead."); } diff --git a/source/gameengine/Expressions/intern/StringValue.cpp b/source/gameengine/Expressions/intern/StringValue.cpp index 366d9d0543f9..7cf4d4047f71 100644 --- a/source/gameengine/Expressions/intern/StringValue.cpp +++ b/source/gameengine/Expressions/intern/StringValue.cpp @@ -37,7 +37,7 @@ CStringValue::CStringValue() * pre: * effect: constructs a new CStringValue containing text txt */ -CStringValue::CStringValue(const char *txt,const char *name,AllocationTYPE alloctype) +CStringValue::CStringValue(const std::string& txt, const std::string& name, AllocationTYPE alloctype) { m_strString = txt; SetName(name); @@ -127,12 +127,12 @@ int CStringValue::GetValueType() -const STR_String CStringValue::GetText() +const std::string CStringValue::GetText() { return m_strString; } -bool CStringValue::IsEqual(const STR_String & other) +bool CStringValue::IsEqual(const std::string & other) { return (m_strString == other); } diff --git a/source/gameengine/Expressions/intern/Value.cpp b/source/gameengine/Expressions/intern/Value.cpp index fc82e83043ba..19d0e08c3079 100644 --- a/source/gameengine/Expressions/intern/Value.cpp +++ b/source/gameengine/Expressions/intern/Value.cpp @@ -143,12 +143,12 @@ effect: deletes the object #define VALUE_POS(val1) (val1)->Calc(VALUE_POS_OPERATOR, val1) #endif -STR_String CValue::op2str(VALUE_OPERATOR op) +std::string CValue::op2str(VALUE_OPERATOR op) { //pre: //ret: the stringrepresentation of operator op - STR_String opmsg; + std::string opmsg; switch (op) { case VALUE_MOD_OPERATOR: opmsg = " % "; @@ -207,7 +207,7 @@ STR_String CValue::op2str(VALUE_OPERATOR op) // // Set property , overwrites and releases a previous property with the same name if needed // -void CValue::SetProperty(const STR_String & name,CValue* ioProperty) +void CValue::SetProperty(const std::string & name,CValue* ioProperty) { if (ioProperty==NULL) { // Check if somebody is setting an empty property @@ -222,29 +222,7 @@ void CValue::SetProperty(const STR_String & name,CValue* ioProperty) oldval->Release(); } else { // Make sure we have a property array - m_pNamedPropertyArray = new std::map; - } - - // Add property at end of array - (*m_pNamedPropertyArray)[name] = ioProperty->AddRef();//->Add(ioProperty); -} - -void CValue::SetProperty(const char* name,CValue* ioProperty) -{ - if (ioProperty==NULL) - { // Check if somebody is setting an empty property - trace("Warning:trying to set empty property!"); - return; - } - - if (m_pNamedPropertyArray) - { // Try to replace property (if so -> exit as soon as we replaced it) - CValue* oldval = (*m_pNamedPropertyArray)[name]; - if (oldval) - oldval->Release(); - } - else { // Make sure we have a property array - m_pNamedPropertyArray = new std::map; + m_pNamedPropertyArray = new std::map; } // Add property at end of array @@ -254,20 +232,10 @@ void CValue::SetProperty(const char* name,CValue* ioProperty) // // Get pointer to a property with name , returns NULL if there is no property named // -CValue* CValue::GetProperty(const STR_String & inName) -{ - if (m_pNamedPropertyArray) { - std::map::iterator it = m_pNamedPropertyArray->find(inName); - if (it != m_pNamedPropertyArray->end()) - return (*it).second; - } - return NULL; -} - -CValue* CValue::GetProperty(const char *inName) +CValue* CValue::GetProperty(const std::string & inName) { if (m_pNamedPropertyArray) { - std::map::iterator it = m_pNamedPropertyArray->find(inName); + std::map::iterator it = m_pNamedPropertyArray->find(inName); if (it != m_pNamedPropertyArray->end()) return (*it).second; } @@ -277,7 +245,7 @@ CValue* CValue::GetProperty(const char *inName) // // Get text description of property with name , returns an empty string if there is no property named // -const STR_String CValue::GetPropertyText(const STR_String & inName) +const std::string CValue::GetPropertyText(const std::string & inName) { CValue *property = GetProperty(inName); if (property) @@ -286,7 +254,7 @@ const STR_String CValue::GetPropertyText(const STR_String & inName) return ""; } -float CValue::GetPropertyNumber(const STR_String& inName,float defnumber) +float CValue::GetPropertyNumber(const std::string& inName,float defnumber) { CValue *property = GetProperty(inName); if (property) @@ -300,12 +268,12 @@ float CValue::GetPropertyNumber(const STR_String& inName,float defnumber) // // Remove the property named , returns true if the property was succesfully removed, false if property was not found or could not be removed // -bool CValue::RemoveProperty(const char *inName) +bool CValue::RemoveProperty(const std::string& inName) { // Check if there are properties at all which can be removed if (m_pNamedPropertyArray) { - std::map::iterator it = m_pNamedPropertyArray->find(inName); + std::map::iterator it = m_pNamedPropertyArray->find(inName); if (it != m_pNamedPropertyArray->end()) { ((*it).second)->Release(); @@ -320,13 +288,13 @@ bool CValue::RemoveProperty(const char *inName) // // Get Property Names // -std::vector CValue::GetPropertyNames() +std::vector CValue::GetPropertyNames() { - std::vector result; + std::vector result; if (!m_pNamedPropertyArray) return result; result.reserve(m_pNamedPropertyArray->size()); - std::map::iterator it; + std::map::iterator it; for (it= m_pNamedPropertyArray->begin(); (it != m_pNamedPropertyArray->end()); it++) { result.push_back((*it).first); @@ -344,11 +312,11 @@ void CValue::ClearProperties() return; // Remove all properties - std::map::iterator it; + std::map::iterator it; for (it= m_pNamedPropertyArray->begin();(it != m_pNamedPropertyArray->end()); it++) { CValue* tmpval = (*it).second; - //STR_String name = (*it).first; + //std::string name = (*it).first; tmpval->Release(); } @@ -365,7 +333,7 @@ void CValue::ClearProperties() void CValue::SetPropertiesModified(bool inModified) { if (!m_pNamedPropertyArray) return; - std::map::iterator it; + std::map::iterator it; for (it= m_pNamedPropertyArray->begin();(it != m_pNamedPropertyArray->end()); it++) ((*it).second)->SetModified(inModified); @@ -379,7 +347,7 @@ void CValue::SetPropertiesModified(bool inModified) bool CValue::IsAnyPropertyModified() { if (!m_pNamedPropertyArray) return false; - std::map::iterator it; + std::map::iterator it; for (it= m_pNamedPropertyArray->begin();(it != m_pNamedPropertyArray->end()); it++) if (((*it).second)->IsModified()) @@ -401,7 +369,7 @@ CValue* CValue::GetProperty(int inIndex) if (m_pNamedPropertyArray) { - std::map::iterator it; + std::map::iterator it; for (it= m_pNamedPropertyArray->begin(); (it != m_pNamedPropertyArray->end()); it++) { if (count++ == inIndex) @@ -486,9 +454,9 @@ void CValue::ProcessReplica() /* was AddDataToReplica in 2.48 */ /* copy all props */ if (m_pNamedPropertyArray) { - std::map *pOldArray = m_pNamedPropertyArray; + std::map *pOldArray = m_pNamedPropertyArray; m_pNamedPropertyArray=NULL; - std::map::iterator it; + std::map::iterator it; for (it= pOldArray->begin(); (it != pOldArray->end()); it++) { CValue *val = (*it).second->GetReplica(); @@ -507,17 +475,17 @@ int CValue::GetValueType() -CValue* CValue::FindIdentifier(const STR_String& identifiername) +CValue* CValue::FindIdentifier(const std::string& identifiername) { CValue* result = NULL; int pos = 0; // if a dot exists, explode the name into pieces to get the subcontext - if ((pos=identifiername.Find('.'))>=0) + if ((pos = identifiername.find('.')) != std::string::npos) { - const STR_String rightstring = identifiername.Right(identifiername.Length() -1 - pos); - const STR_String leftstring = identifiername.Left(pos); + const std::string rightstring = identifiername.substr(pos + 1); + const std::string leftstring = identifiername.substr(0, pos); CValue* tempresult = GetProperty(leftstring); if (tempresult) { @@ -541,13 +509,13 @@ CValue* CValue::FindIdentifier(const STR_String& identifiername) PyAttributeDef CValue::Attributes[] = { KX_PYATTRIBUTE_RO_FUNCTION("name", CValue, pyattr_get_name), - { NULL } //Sentinel + KX_PYATTRIBUTE_NULL //Sentinel }; PyObject *CValue::pyattr_get_name(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { CValue * self = static_cast (self_v); - return PyUnicode_From_STR_String(self->GetName()); + return PyUnicode_FromStdString(self->GetName()); } /** @@ -640,10 +608,10 @@ PyObject *CValue::ConvertKeysToPython(void) PyObject *pylist= PyList_New(m_pNamedPropertyArray->size()); Py_ssize_t i= 0; - std::map::iterator it; + std::map::iterator it; for (it= m_pNamedPropertyArray->begin(); (it != m_pNamedPropertyArray->end()); it++) { - PyList_SET_ITEM(pylist, i++, PyUnicode_From_STR_String((*it).first)); + PyList_SET_ITEM(pylist, i++, PyUnicode_FromStdString((*it).first)); } return pylist; @@ -685,7 +653,7 @@ void CValue::SetValue(CValue* newval) assertd(newval->GetNumber() == 10121969); } -const STR_String CValue::GetText() +const std::string CValue::GetText() { return GetName(); } @@ -695,7 +663,7 @@ double CValue::GetNumber() return -1.0; } -void CValue::SetName(const char *name) +void CValue::SetName(const std::string& name) { } diff --git a/source/gameengine/GameLogic/CMakeLists.txt b/source/gameengine/GameLogic/CMakeLists.txt index 1e6736719c29..f200e301c9aa 100644 --- a/source/gameengine/GameLogic/CMakeLists.txt +++ b/source/gameengine/GameLogic/CMakeLists.txt @@ -38,6 +38,7 @@ set(INC set(INC_SYS ../../../intern/moto/include + ${BOOST_INCLUDE_DIR} ) set(SRC diff --git a/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp b/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp index cb9f72e4e606..1c62fb549cfb 100644 --- a/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp +++ b/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp @@ -138,7 +138,7 @@ void SCA_2DFilterActuator::SetScene(SCA_IScene *scene) m_scene = scene; } -void SCA_2DFilterActuator::SetShaderText(const char *text) +void SCA_2DFilterActuator::SetShaderText(const std::string& text) { m_shaderText = text; } @@ -183,7 +183,7 @@ PyAttributeDef SCA_2DFilterActuator::Attributes[] = { KX_PYATTRIBUTE_ENUM_RW("mode", RAS_2DFilterManager::FILTER_ENABLED, RAS_2DFilterManager::FILTER_NUMBER_OF_FILTERS, false, SCA_2DFilterActuator, m_type), KX_PYATTRIBUTE_INT_RW("passNumber", 0, 100, true, SCA_2DFilterActuator, m_int_arg), KX_PYATTRIBUTE_FLOAT_RW("value", 0.0, 100.0, SCA_2DFilterActuator, m_float_arg), - { NULL } //Sentinel + KX_PYATTRIBUTE_NULL //Sentinel }; #endif diff --git a/source/gameengine/GameLogic/SCA_2DFilterActuator.h b/source/gameengine/GameLogic/SCA_2DFilterActuator.h index 6c278f9a6bfc..f9730e8c8e72 100644 --- a/source/gameengine/GameLogic/SCA_2DFilterActuator.h +++ b/source/gameengine/GameLogic/SCA_2DFilterActuator.h @@ -42,12 +42,12 @@ class SCA_2DFilterActuator : public SCA_IActuator Py_Header private: - std::vector m_propNames; + std::vector m_propNames; int m_type; short m_disableMotionBlur; float m_float_arg; int m_int_arg; - STR_String m_shaderText; + std::string m_shaderText; RAS_IRasterizer* m_rasterizer; RAS_2DFilterManager *m_filterManager; SCA_IScene* m_scene; @@ -63,7 +63,7 @@ class SCA_2DFilterActuator : public SCA_IActuator RAS_2DFilterManager *filterManager, SCA_IScene* scene); - void SetShaderText(const char *text); + void SetShaderText(const std::string& text); virtual ~SCA_2DFilterActuator(); virtual bool Update(); diff --git a/source/gameengine/GameLogic/SCA_ANDController.cpp b/source/gameengine/GameLogic/SCA_ANDController.cpp index 7820753dfc19..e3cc862fc992 100644 --- a/source/gameengine/GameLogic/SCA_ANDController.cpp +++ b/source/gameengine/GameLogic/SCA_ANDController.cpp @@ -125,7 +125,7 @@ PyMethodDef SCA_ANDController::Methods[] = { }; PyAttributeDef SCA_ANDController::Attributes[] = { - { NULL } //Sentinel + KX_PYATTRIBUTE_NULL //Sentinel }; #endif // WITH_PYTHON /* eof */ diff --git a/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp b/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp index 8b7702228ce6..9ac0b8e64bc5 100644 --- a/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp +++ b/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp @@ -42,7 +42,7 @@ SCA_ActuatorSensor::SCA_ActuatorSensor(SCA_EventManager* eventmgr, SCA_IObject* gameobj, - const STR_String& actname) + const std::string& actname) : SCA_ISensor(gameobj,eventmgr), m_checkactname(actname) { @@ -151,7 +151,7 @@ PyMethodDef SCA_ActuatorSensor::Methods[] = { PyAttributeDef SCA_ActuatorSensor::Attributes[] = { KX_PYATTRIBUTE_STRING_RW_CHECK("actuator",0,MAX_PROP_NAME,false,SCA_ActuatorSensor,m_checkactname,CheckActuator), - { NULL } //Sentinel + KX_PYATTRIBUTE_NULL //Sentinel }; int SCA_ActuatorSensor::CheckActuator(void *self, const PyAttributeDef*) diff --git a/source/gameengine/GameLogic/SCA_ActuatorSensor.h b/source/gameengine/GameLogic/SCA_ActuatorSensor.h index 6005bd3ac6cb..e521e78a8f5b 100644 --- a/source/gameengine/GameLogic/SCA_ActuatorSensor.h +++ b/source/gameengine/GameLogic/SCA_ActuatorSensor.h @@ -38,7 +38,7 @@ class SCA_ActuatorSensor : public SCA_ISensor { Py_Header - STR_String m_checkactname; + std::string m_checkactname; bool m_lastresult; bool m_midresult; protected: @@ -46,7 +46,7 @@ class SCA_ActuatorSensor : public SCA_ISensor public: SCA_ActuatorSensor(class SCA_EventManager* eventmgr, SCA_IObject* gameobj, - const STR_String& actname); + const std::string& actname); virtual ~SCA_ActuatorSensor(); virtual CValue* GetReplica(); diff --git a/source/gameengine/GameLogic/SCA_AlwaysSensor.cpp b/source/gameengine/GameLogic/SCA_AlwaysSensor.cpp index 1a6a82a33eb4..7bccc1a0cd4b 100644 --- a/source/gameengine/GameLogic/SCA_AlwaysSensor.cpp +++ b/source/gameengine/GameLogic/SCA_AlwaysSensor.cpp @@ -131,7 +131,7 @@ PyMethodDef SCA_AlwaysSensor::Methods[] = { }; PyAttributeDef SCA_AlwaysSensor::Attributes[] = { - { NULL } //Sentinel + KX_PYATTRIBUTE_NULL //Sentinel }; #endif diff --git a/source/gameengine/GameLogic/SCA_DelaySensor.cpp b/source/gameengine/GameLogic/SCA_DelaySensor.cpp index af751cffc2e7..16eaef13a0f2 100644 --- a/source/gameengine/GameLogic/SCA_DelaySensor.cpp +++ b/source/gameengine/GameLogic/SCA_DelaySensor.cpp @@ -162,7 +162,7 @@ PyAttributeDef SCA_DelaySensor::Attributes[] = { KX_PYATTRIBUTE_INT_RW("delay",0,100000,true,SCA_DelaySensor,m_delay), KX_PYATTRIBUTE_INT_RW("duration",0,100000,true,SCA_DelaySensor,m_duration), KX_PYATTRIBUTE_BOOL_RW("repeat",SCA_DelaySensor,m_repeat), - { NULL } //Sentinel + KX_PYATTRIBUTE_NULL //Sentinel }; #endif // WITH_PYTHON diff --git a/source/gameengine/GameLogic/SCA_ExpressionController.cpp b/source/gameengine/GameLogic/SCA_ExpressionController.cpp index df1b4d6838c6..831d9073a25f 100644 --- a/source/gameengine/GameLogic/SCA_ExpressionController.cpp +++ b/source/gameengine/GameLogic/SCA_ExpressionController.cpp @@ -47,7 +47,7 @@ /* ------------------------------------------------------------------------- */ SCA_ExpressionController::SCA_ExpressionController(SCA_IObject* gameobj, - const STR_String& exprtext) + const std::string& exprtext) :SCA_IController(gameobj), m_exprText(exprtext), m_exprCache(NULL) @@ -127,7 +127,7 @@ void SCA_ExpressionController::Trigger(SCA_LogicManager* logicmgr) -CValue* SCA_ExpressionController::FindIdentifier(const STR_String& identifiername) +CValue* SCA_ExpressionController::FindIdentifier(const std::string& identifiername) { CValue* identifierval = NULL; diff --git a/source/gameengine/GameLogic/SCA_ExpressionController.h b/source/gameengine/GameLogic/SCA_ExpressionController.h index c16944ccde1a..4c34e7676543 100644 --- a/source/gameengine/GameLogic/SCA_ExpressionController.h +++ b/source/gameengine/GameLogic/SCA_ExpressionController.h @@ -40,17 +40,17 @@ class SCA_ExpressionController : public SCA_IController { // Py_Header - STR_String m_exprText; + std::string m_exprText; CExpression* m_exprCache; public: SCA_ExpressionController(SCA_IObject* gameobj, - const STR_String& exprtext); + const std::string& exprtext); virtual ~SCA_ExpressionController(); virtual CValue* GetReplica(); virtual void Trigger(SCA_LogicManager* logicmgr); - virtual CValue* FindIdentifier(const STR_String& identifiername); + virtual CValue* FindIdentifier(const std::string& identifiername); /** * used to release the expression cache * so that self references are removed before the controller itself is released diff --git a/source/gameengine/GameLogic/SCA_IController.cpp b/source/gameengine/GameLogic/SCA_IController.cpp index 1ce1c6a38951..13b611e98d45 100644 --- a/source/gameengine/GameLogic/SCA_IController.cpp +++ b/source/gameengine/GameLogic/SCA_IController.cpp @@ -231,7 +231,7 @@ PyAttributeDef SCA_IController::Attributes[] = { KX_PYATTRIBUTE_RO_FUNCTION("sensors", SCA_IController, pyattr_get_sensors), KX_PYATTRIBUTE_RO_FUNCTION("actuators", SCA_IController, pyattr_get_actuators), KX_PYATTRIBUTE_BOOL_RW("useHighPriority",SCA_IController,m_bookmark), - { NULL } //Sentinel + KX_PYATTRIBUTE_NULL //Sentinel }; PyObject *SCA_IController::pyattr_get_state(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) @@ -250,9 +250,9 @@ static PyObject *sca_icontroller_get_sensors_item_cb(void *self_v, int index) return ((SCA_IController *)self_v)->GetLinkedSensors()[index]->GetProxy(); } -static const char *sca_icontroller_get_sensors_item_name_cb(void *self_v, int index) +static const std::string sca_icontroller_get_sensors_item_name_cb(void *self_v, int index) { - return ((SCA_IController *)self_v)->GetLinkedSensors()[index]->GetName().ReadPtr(); + return ((SCA_IController *)self_v)->GetLinkedSensors()[index]->GetName(); } PyObject *SCA_IController::pyattr_get_sensors(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) @@ -276,9 +276,9 @@ static PyObject *sca_icontroller_get_actuators_item_cb(void *self_v, int index) return ((SCA_IController *)self_v)->GetLinkedActuators()[index]->GetProxy(); } -static const char *sca_icontroller_get_actuators_item_name_cb(void *self_v, int index) +static const std::string sca_icontroller_get_actuators_item_name_cb(void *self_v, int index) { - return ((SCA_IController *)self_v)->GetLinkedActuators()[index]->GetName().ReadPtr(); + return ((SCA_IController *)self_v)->GetLinkedActuators()[index]->GetName(); } PyObject *SCA_IController::pyattr_get_actuators(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) diff --git a/source/gameengine/GameLogic/SCA_ILogicBrick.cpp b/source/gameengine/GameLogic/SCA_ILogicBrick.cpp index 581e178c864d..5d9e4f6a8155 100644 --- a/source/gameengine/GameLogic/SCA_ILogicBrick.cpp +++ b/source/gameengine/GameLogic/SCA_ILogicBrick.cpp @@ -102,20 +102,20 @@ CValue* SCA_ILogicBrick::CalcFinal(VALUE_DATA_TYPE dtype, return result; } -const STR_String SCA_ILogicBrick::GetText() +const std::string SCA_ILogicBrick::GetText() { - if (m_name.Length()) + if (m_name.size()) return m_name; return m_text; } -STR_String SCA_ILogicBrick::GetName() +std::string SCA_ILogicBrick::GetName() { return m_name; } -void SCA_ILogicBrick::SetName(const char *name) +void SCA_ILogicBrick::SetName(const std::string& name) { m_name = name; } @@ -203,7 +203,7 @@ PyAttributeDef SCA_ILogicBrick::Attributes[] = { KX_PYATTRIBUTE_RO_FUNCTION("owner", SCA_ILogicBrick, pyattr_get_owner), KX_PYATTRIBUTE_INT_RW("executePriority",0,100000,false,SCA_ILogicBrick,m_Execute_Priority), KX_PYATTRIBUTE_STRING_RO("name", SCA_ILogicBrick, m_name), - {NULL} //Sentinel + KX_PYATTRIBUTE_NULL //Sentinel }; int SCA_ILogicBrick::CheckProperty(void *self, const PyAttributeDef *attrdef) @@ -213,7 +213,7 @@ int SCA_ILogicBrick::CheckProperty(void *self, const PyAttributeDef *attrdef) return 1; } SCA_ILogicBrick* brick = reinterpret_cast(self); - STR_String* var = reinterpret_cast((char*)self+attrdef->m_offset); + std::string* var = reinterpret_cast((char*)self+attrdef->m_offset); CValue* prop = brick->GetParent()->FindIdentifier(*var); bool error = prop->IsError(); prop->Release(); diff --git a/source/gameengine/GameLogic/SCA_ILogicBrick.h b/source/gameengine/GameLogic/SCA_ILogicBrick.h index 990f26f6b9e3..a4dba7ffb493 100644 --- a/source/gameengine/GameLogic/SCA_ILogicBrick.h +++ b/source/gameengine/GameLogic/SCA_ILogicBrick.h @@ -51,8 +51,8 @@ class SCA_ILogicBrick : public CValue, public SG_QList bool m_bActive; CValue* m_eventval; - STR_String m_text; - STR_String m_name; + std::string m_text; + std::string m_name; //unsigned long m_drawcolor; void RegisterEvent(CValue* eventval); void RemoveEvent(); @@ -75,9 +75,9 @@ class SCA_ILogicBrick : public CValue, public SG_QList virtual CValue* Calc(VALUE_OPERATOR op, CValue *val); virtual CValue* CalcFinal(VALUE_DATA_TYPE dtype, VALUE_OPERATOR op, CValue *val); - virtual const STR_String GetText(); - virtual STR_String GetName(); - virtual void SetName(const char *); + virtual const std::string GetText(); + virtual std::string GetName(); + virtual void SetName(const std::string& name); bool IsActive() { diff --git a/source/gameengine/GameLogic/SCA_IObject.cpp b/source/gameengine/GameLogic/SCA_IObject.cpp index 9a193d7549e3..aaef566a3aeb 100644 --- a/source/gameengine/GameLogic/SCA_IObject.cpp +++ b/source/gameengine/GameLogic/SCA_IObject.cpp @@ -197,7 +197,7 @@ void SCA_IObject::ReParentLogic() -SCA_ISensor* SCA_IObject::FindSensor(const STR_String& sensorname) +SCA_ISensor* SCA_IObject::FindSensor(const std::string& sensorname) { SCA_ISensor* foundsensor = NULL; @@ -214,7 +214,7 @@ SCA_ISensor* SCA_IObject::FindSensor(const STR_String& sensorname) -SCA_IController* SCA_IObject::FindController(const STR_String& controllername) +SCA_IController* SCA_IObject::FindController(const std::string& controllername) { SCA_IController* foundcontroller = NULL; @@ -231,7 +231,7 @@ SCA_IController* SCA_IObject::FindController(const STR_String& controllername) -SCA_IActuator* SCA_IObject::FindActuator(const STR_String& actuatorname) +SCA_IActuator* SCA_IObject::FindActuator(const std::string& actuatorname) { SCA_IActuator* foundactuator = NULL; @@ -343,7 +343,7 @@ PyMethodDef SCA_IObject::Methods[] = { }; PyAttributeDef SCA_IObject::Attributes[] = { - { NULL } //Sentinel + KX_PYATTRIBUTE_NULL //Sentinel }; #endif // WITH_PYTHON diff --git a/source/gameengine/GameLogic/SCA_IObject.h b/source/gameengine/GameLogic/SCA_IObject.h index d51dcf29c54c..425895db51c0 100644 --- a/source/gameengine/GameLogic/SCA_IObject.h +++ b/source/gameengine/GameLogic/SCA_IObject.h @@ -160,9 +160,9 @@ class SCA_IObject : public CValue */ virtual bool UnlinkObject(SCA_IObject* clientobj) { return false; } - SCA_ISensor* FindSensor(const STR_String& sensorname); - SCA_IActuator* FindActuator(const STR_String& actuatorname); - SCA_IController* FindController(const STR_String& controllername); + SCA_ISensor* FindSensor(const std::string& sensorname); + SCA_IActuator* FindActuator(const std::string& actuatorname); + SCA_IController* FindController(const std::string& controllername); void SetCurrentTime(float currentTime) {} diff --git a/source/gameengine/GameLogic/SCA_IScene.cpp b/source/gameengine/GameLogic/SCA_IScene.cpp index 453fbc0b78c8..820604973c24 100644 --- a/source/gameengine/GameLogic/SCA_IScene.cpp +++ b/source/gameengine/GameLogic/SCA_IScene.cpp @@ -70,11 +70,11 @@ std::vector& SCA_IScene::GetDebugProperties() } -bool SCA_IScene::PropertyInDebugList( class CValue *gameobj, const STR_String &name ) +bool SCA_IScene::PropertyInDebugList( class CValue *gameobj, const std::string &name ) { for (std::vector::iterator it = m_debugList.begin(); !(it==m_debugList.end());++it) { - STR_String debugname = (*it)->m_name; + std::string debugname = (*it)->m_name; CValue *debugobj = (*it)->m_obj; if (debugobj == gameobj && debugname == name) @@ -98,7 +98,7 @@ bool SCA_IScene::ObjectInDebugList( class CValue *gameobj ) void SCA_IScene::AddDebugProperty(class CValue* debugprop, - const STR_String &name) + const std::string &name) { if (m_debugList.size() < DEBUG_MAX_DISPLAY) { SCA_DebugProp* dprop = new SCA_DebugProp(); @@ -111,11 +111,11 @@ void SCA_IScene::AddDebugProperty(class CValue* debugprop, void SCA_IScene::RemoveDebugProperty(class CValue *gameobj, - const STR_String &name) + const std::string &name) { std::vector::iterator it = m_debugList.begin(); while (it != m_debugList.end()) { - STR_String debugname = (*it)->m_name; + std::string debugname = (*it)->m_name; CValue *debugobj = (*it)->m_obj; if (debugobj == gameobj && debugname == name) { diff --git a/source/gameengine/GameLogic/SCA_IScene.h b/source/gameengine/GameLogic/SCA_IScene.h index d7a25c92125a..fd15fb3a32ab 100644 --- a/source/gameengine/GameLogic/SCA_IScene.h +++ b/source/gameengine/GameLogic/SCA_IScene.h @@ -34,7 +34,7 @@ #include -#include "STR_String.h" +#include #include "RAS_2DFilterData.h" #ifdef WITH_CXX_GUARDEDALLOC @@ -46,7 +46,7 @@ struct SCA_DebugProp { class CValue* m_obj; - STR_String m_name; + std::string m_name; SCA_DebugProp(); ~SCA_DebugProp(); }; @@ -67,11 +67,11 @@ class SCA_IScene virtual void ReplaceMesh(class CValue* gameobj, void* meshobj, bool use_gfx, bool use_phys)=0; std::vector& GetDebugProperties(); - bool PropertyInDebugList(class CValue *gameobj, const STR_String &name); + bool PropertyInDebugList(class CValue *gameobj, const std::string &name); bool ObjectInDebugList(class CValue *gameobj); void RemoveAllDebugProperties(); - void AddDebugProperty(class CValue* debugprop, const STR_String &name); - void RemoveDebugProperty(class CValue *gameobj, const STR_String &name); + void AddDebugProperty(class CValue* debugprop, const std::string &name); + void RemoveDebugProperty(class CValue *gameobj, const std::string &name); void RemoveObjectDebugProperties(class CValue* gameobj); #ifdef WITH_CXX_GUARDEDALLOC diff --git a/source/gameengine/GameLogic/SCA_ISensor.cpp b/source/gameengine/GameLogic/SCA_ISensor.cpp index 67035b73caee..e743f02456ee 100644 --- a/source/gameengine/GameLogic/SCA_ISensor.cpp +++ b/source/gameengine/GameLogic/SCA_ISensor.cpp @@ -373,7 +373,7 @@ PyAttributeDef SCA_ISensor::Attributes[] = { KX_PYATTRIBUTE_RO_FUNCTION("pos_ticks", SCA_ISensor, pyattr_get_posTicks), KX_PYATTRIBUTE_RO_FUNCTION("neg_ticks", SCA_ISensor, pyattr_get_negTicks), KX_PYATTRIBUTE_RW_FUNCTION("frequency", SCA_ISensor, pyattr_get_frequency, pyattr_set_frequency), - { NULL } //Sentinel + KX_PYATTRIBUTE_NULL //Sentinel }; diff --git a/source/gameengine/GameLogic/SCA_InputEvent.cpp b/source/gameengine/GameLogic/SCA_InputEvent.cpp index 0d84352c4030..0fd48b2f58e4 100644 --- a/source/gameengine/GameLogic/SCA_InputEvent.cpp +++ b/source/gameengine/GameLogic/SCA_InputEvent.cpp @@ -117,7 +117,7 @@ PyAttributeDef SCA_InputEvent::Attributes[] = { KX_PYATTRIBUTE_RO_FUNCTION("queue", SCA_InputEvent, pyattr_get_queue), KX_PYATTRIBUTE_RO_FUNCTION("values", SCA_InputEvent, pyattr_get_values), KX_PYATTRIBUTE_INT_RO("type", SCA_InputEvent, m_type), - {NULL} //Sentinel + KX_PYATTRIBUTE_NULL //Sentinel }; int SCA_InputEvent::get_status_size_cb(void *self_v) diff --git a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp index be3256d7b3c0..7a4451e209ed 100644 --- a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp +++ b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp @@ -262,7 +262,7 @@ PyAttributeDef SCA_JoystickSensor::Attributes[] = { KX_PYATTRIBUTE_RO_FUNCTION("numButtons", SCA_JoystickSensor, pyattr_get_num_buttons), KX_PYATTRIBUTE_RO_FUNCTION("numHats", SCA_JoystickSensor, pyattr_get_num_hats), KX_PYATTRIBUTE_RO_FUNCTION("connected", SCA_JoystickSensor, pyattr_get_connected), - { NULL } //Sentinel + KX_PYATTRIBUTE_NULL //Sentinel }; /* get button active list -------------------------------------------------- */ diff --git a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp b/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp index e025b41df663..8bf0226c1fbf 100644 --- a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp +++ b/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp @@ -53,8 +53,8 @@ SCA_KeyboardSensor::SCA_KeyboardSensor(SCA_KeyboardManager* keybdmgr, short int qual, short int qual2, bool bAllKeys, - const STR_String& targetProp, - const STR_String& toggleProp, + const std::string& targetProp, + const std::string& toggleProp, SCA_IObject* gameobj, short int exitKey) :SCA_ISensor(gameobj,keybdmgr), @@ -252,8 +252,8 @@ void SCA_KeyboardSensor::LogKeystrokes() std::wstring proptext = L""; { - const STR_String utf8str = tprop->GetText(); - const char *utf8buf = utf8str.ReadPtr(); + const std::string utf8str = tprop->GetText(); + const char *utf8buf = utf8str.c_str(); int utf8len = BLI_strlen_utf8(utf8buf); if (utf8len != 0) { wchar_t *wcharbuf = new wchar_t[utf8len + 1]; @@ -282,14 +282,14 @@ void SCA_KeyboardSensor::LogKeystrokes() } { - STR_String newpropstr = ""; + std::string newpropstr = ""; - const wchar_t *cproptext = proptext.data(); + const wchar_t *cproptext = proptext.c_str(); size_t utf8len = BLI_wstrlen_utf8(cproptext); if (utf8len != 0) { char *utf8buf = new char[utf8len + 1]; BLI_strncpy_wchar_as_utf8(utf8buf, cproptext, utf8len + 1); - newpropstr = STR_String(utf8buf); + newpropstr = std::string(utf8buf); delete utf8buf; } @@ -371,7 +371,7 @@ PyAttributeDef SCA_KeyboardSensor::Attributes[] = { KX_PYATTRIBUTE_SHORT_RW("hold2",0,SCA_IInputDevice::ENDKEY,true,SCA_KeyboardSensor,m_qual2), KX_PYATTRIBUTE_STRING_RW("toggleProperty",0,MAX_PROP_NAME,false,SCA_KeyboardSensor,m_toggleprop), KX_PYATTRIBUTE_STRING_RW("targetProperty",0,MAX_PROP_NAME,false,SCA_KeyboardSensor,m_targetprop), - { NULL } //Sentinel + KX_PYATTRIBUTE_NULL //Sentinel }; diff --git a/source/gameengine/GameLogic/SCA_KeyboardSensor.h b/source/gameengine/GameLogic/SCA_KeyboardSensor.h index e82542d79c42..687b6706b1f7 100644 --- a/source/gameengine/GameLogic/SCA_KeyboardSensor.h +++ b/source/gameengine/GameLogic/SCA_KeyboardSensor.h @@ -63,14 +63,14 @@ class SCA_KeyboardSensor : public SCA_ISensor * The name of the property to which logged text is appended. If * this property is not defined, no logging takes place. */ - STR_String m_targetprop; + std::string m_targetprop; /** * The property that indicates whether or not to log text when in * logging mode. If the property equals 0, no logging is done. For * all other values, logging is active. Logging can only become * active if there is a property to log to. Logging is independent * from hotkey settings. */ - STR_String m_toggleprop; + std::string m_toggleprop; /** * Log the keystrokes from the current input buffer. @@ -88,8 +88,8 @@ class SCA_KeyboardSensor : public SCA_ISensor short int qual, short int qual2, bool bAllKeys, - const STR_String& targetProp, - const STR_String& toggleProp, + const std::string& targetProp, + const std::string& toggleProp, SCA_IObject* gameobj, short int exitKey); virtual ~SCA_KeyboardSensor(); diff --git a/source/gameengine/GameLogic/SCA_LogicManager.cpp b/source/gameengine/GameLogic/SCA_LogicManager.cpp index 3df6c6b328e5..8f8b1ec4b1e7 100644 --- a/source/gameengine/GameLogic/SCA_LogicManager.cpp +++ b/source/gameengine/GameLogic/SCA_LogicManager.cpp @@ -60,7 +60,7 @@ SCA_LogicManager::~SCA_LogicManager() // this kind of fixes bug 398 but breakes games, so better leave it out for now. // a removed object's gameobject (and logicbricks and stuff) didn't get released // because it was still in the m_mapStringToGameObjects map. -void SCA_LogicManager::RemoveGameObject(const STR_String& gameobjname) +void SCA_LogicManager::RemoveGameObject(const std::string& gameobjname) { int numgameobj = m_mapStringToGameObjects.size(); for (int i = 0; i < numgameobj; i++) @@ -87,22 +87,22 @@ void SCA_LogicManager::RegisterEventManager(SCA_EventManager* eventmgr) -void SCA_LogicManager::RegisterGameObjectName(const STR_String& gameobjname, +void SCA_LogicManager::RegisterGameObjectName(const std::string& gameobjname, CValue* gameobj) { - STR_HashedString mn = gameobjname; + std::string mn = gameobjname; m_mapStringToGameObjects[mn] = gameobj; } -void SCA_LogicManager::UnregisterGameObjectName(const STR_String& gameobjname) +void SCA_LogicManager::UnregisterGameObjectName(const std::string& gameobjname) { m_mapStringToGameObjects.erase(gameobjname); } -void SCA_LogicManager::RegisterGameMeshName(const STR_String& gamemeshname, void* blendobj) +void SCA_LogicManager::RegisterGameMeshName(const std::string& gamemeshname, void* blendobj) { - STR_HashedString mn = gamemeshname; + std::string mn = gamemeshname; m_map_gamemeshname_to_blendobj[mn] = blendobj; } @@ -121,9 +121,9 @@ void SCA_LogicManager::UnregisterGameObj(void* blendobj, CValue* gameobj) } } -CValue* SCA_LogicManager::GetGameObjectByName(const STR_String& gameobjname) +CValue* SCA_LogicManager::GetGameObjectByName(const std::string& gameobjname) { - STR_HashedString mn = gameobjname; + std::string mn = gameobjname; return m_mapStringToGameObjects[mn]; } @@ -135,9 +135,9 @@ CValue* SCA_LogicManager::FindGameObjByBlendObj(void* blendobj) -void* SCA_LogicManager::FindBlendObjByGameMeshName(const STR_String& gamemeshname) +void* SCA_LogicManager::FindBlendObjByGameMeshName(const std::string& gamemeshname) { - STR_HashedString mn = gamemeshname; + std::string mn = gamemeshname; return m_map_gamemeshname_to_blendobj[mn]; } @@ -247,38 +247,38 @@ void SCA_LogicManager::UpdateFrame(double curtime, bool frame) -void *SCA_LogicManager::GetActionByName(const STR_String& actname) +void *SCA_LogicManager::GetActionByName(const std::string& actname) { - STR_HashedString an = actname; + std::string an = actname; return m_mapStringToActions[an]; } -void* SCA_LogicManager::GetMeshByName(const STR_String& meshname) +void* SCA_LogicManager::GetMeshByName(const std::string& meshname) { - STR_HashedString mn = meshname; + std::string mn = meshname; return m_mapStringToMeshes[mn]; } -void SCA_LogicManager::RegisterMeshName(const STR_String& meshname,void* mesh) +void SCA_LogicManager::RegisterMeshName(const std::string& meshname,void* mesh) { - STR_HashedString mn = meshname; + std::string mn = meshname; m_mapStringToMeshes[mn] = mesh; } -void SCA_LogicManager::UnregisterMeshName(const STR_String& meshname,void* mesh) +void SCA_LogicManager::UnregisterMeshName(const std::string& meshname,void* mesh) { - STR_HashedString mn = meshname; + std::string mn = meshname; m_mapStringToMeshes.erase(mn); } -void SCA_LogicManager::RegisterActionName(const STR_String& actname,void* action) +void SCA_LogicManager::RegisterActionName(const std::string& actname,void* action) { - STR_HashedString an = actname; + std::string an = actname; m_mapStringToActions[an] = action; } diff --git a/source/gameengine/GameLogic/SCA_LogicManager.h b/source/gameengine/GameLogic/SCA_LogicManager.h index d0f54ebd2f8b..fa4c75f38ff0 100644 --- a/source/gameengine/GameLogic/SCA_LogicManager.h +++ b/source/gameengine/GameLogic/SCA_LogicManager.h @@ -39,7 +39,7 @@ #include #include -#include "STR_HashedString.h" +#include #include "EXP_Value.h" #include "SG_QList.h" @@ -77,11 +77,11 @@ class SCA_LogicManager // need to find better way for this // also known as FactoryManager... - std::map m_mapStringToGameObjects; - std::map m_mapStringToMeshes; - std::map m_mapStringToActions; + std::map m_mapStringToGameObjects; + std::map m_mapStringToMeshes; + std::map m_mapStringToActions; - std::map m_map_gamemeshname_to_blendobj; + std::map m_map_gamemeshname_to_blendobj; std::map m_map_blendobj_to_gameobj; public: SCA_LogicManager(); @@ -108,7 +108,7 @@ class SCA_LogicManager SCA_EventManager* FindEventManager(int eventmgrtype); std::vector GetEventManagers() { return m_eventmanagers; } - void RemoveGameObject(const STR_String& gameobjname); + void RemoveGameObject(const std::string& gameobjname); /** * remove Logic Bricks from the running logicmanager @@ -119,22 +119,22 @@ class SCA_LogicManager // for the scripting... needs a FactoryManager later (if we would have time... ;) - void RegisterMeshName(const STR_String& meshname,void* mesh); - void UnregisterMeshName(const STR_String& meshname,void* mesh); - std::map& GetMeshMap() { return m_mapStringToMeshes; } - std::map& GetActionMap() { return m_mapStringToActions; } + void RegisterMeshName(const std::string& meshname,void* mesh); + void UnregisterMeshName(const std::string& meshname,void* mesh); + std::map& GetMeshMap() { return m_mapStringToMeshes; } + std::map& GetActionMap() { return m_mapStringToActions; } - void RegisterActionName(const STR_String& actname,void* action); + void RegisterActionName(const std::string& actname,void* action); - void* GetActionByName (const STR_String& actname); - void* GetMeshByName(const STR_String& meshname); + void* GetActionByName (const std::string& actname); + void* GetMeshByName(const std::string& meshname); - void RegisterGameObjectName(const STR_String& gameobjname,CValue* gameobj); - void UnregisterGameObjectName(const STR_String& gameobjname); - class CValue* GetGameObjectByName(const STR_String& gameobjname); + void RegisterGameObjectName(const std::string& gameobjname,CValue* gameobj); + void UnregisterGameObjectName(const std::string& gameobjname); + class CValue* GetGameObjectByName(const std::string& gameobjname); - void RegisterGameMeshName(const STR_String& gamemeshname, void* blendobj); - void* FindBlendObjByGameMeshName(const STR_String& gamemeshname); + void RegisterGameMeshName(const std::string& gamemeshname, void* blendobj); + void* FindBlendObjByGameMeshName(const std::string& gamemeshname); void RegisterGameObj(void* blendobj, CValue* gameobj); void UnregisterGameObj(void* blendobj, CValue* gameobj); diff --git a/source/gameengine/GameLogic/SCA_MouseSensor.cpp b/source/gameengine/GameLogic/SCA_MouseSensor.cpp index 94dfed46a4dc..e03acd7ac79f 100644 --- a/source/gameengine/GameLogic/SCA_MouseSensor.cpp +++ b/source/gameengine/GameLogic/SCA_MouseSensor.cpp @@ -281,7 +281,7 @@ int SCA_MouseSensor::UpdateHotkeyPy(void *self, const PyAttributeDef*) PyAttributeDef SCA_MouseSensor::Attributes[] = { KX_PYATTRIBUTE_SHORT_RW_CHECK("mode",KX_MOUSESENSORMODE_NODEF,KX_MOUSESENSORMODE_MAX-1,true,SCA_MouseSensor,m_mousemode,UpdateHotkeyPy), KX_PYATTRIBUTE_SHORT_LIST_RO("position",SCA_MouseSensor,m_x,2), - { NULL } //Sentinel + KX_PYATTRIBUTE_NULL //Sentinel }; #endif // WITH_PYTHON diff --git a/source/gameengine/GameLogic/SCA_NANDController.cpp b/source/gameengine/GameLogic/SCA_NANDController.cpp index f1d005713dbb..99293f2f876c 100644 --- a/source/gameengine/GameLogic/SCA_NANDController.cpp +++ b/source/gameengine/GameLogic/SCA_NANDController.cpp @@ -125,7 +125,7 @@ PyMethodDef SCA_NANDController::Methods[] = { }; PyAttributeDef SCA_NANDController::Attributes[] = { - { NULL } //Sentinel + KX_PYATTRIBUTE_NULL //Sentinel }; #endif diff --git a/source/gameengine/GameLogic/SCA_NORController.cpp b/source/gameengine/GameLogic/SCA_NORController.cpp index 7f4ce44e0c75..2a904f7818b6 100644 --- a/source/gameengine/GameLogic/SCA_NORController.cpp +++ b/source/gameengine/GameLogic/SCA_NORController.cpp @@ -125,7 +125,7 @@ PyMethodDef SCA_NORController::Methods[] = { }; PyAttributeDef SCA_NORController::Attributes[] = { - { NULL } //Sentinel + KX_PYATTRIBUTE_NULL //Sentinel }; #endif // WITH_PYTHON diff --git a/source/gameengine/GameLogic/SCA_ORController.cpp b/source/gameengine/GameLogic/SCA_ORController.cpp index 13379d21e2df..13f4adac3568 100644 --- a/source/gameengine/GameLogic/SCA_ORController.cpp +++ b/source/gameengine/GameLogic/SCA_ORController.cpp @@ -121,7 +121,7 @@ PyMethodDef SCA_ORController::Methods[] = { }; PyAttributeDef SCA_ORController::Attributes[] = { - { NULL } //Sentinel + KX_PYATTRIBUTE_NULL //Sentinel }; #endif // WITH_PYTHON diff --git a/source/gameengine/GameLogic/SCA_PropertyActuator.cpp b/source/gameengine/GameLogic/SCA_PropertyActuator.cpp index 42b2f74b37dd..4db9a1d2f063 100644 --- a/source/gameengine/GameLogic/SCA_PropertyActuator.cpp +++ b/source/gameengine/GameLogic/SCA_PropertyActuator.cpp @@ -44,7 +44,7 @@ /* Native functions */ /* ------------------------------------------------------------------------- */ -SCA_PropertyActuator::SCA_PropertyActuator(SCA_IObject* gameobj,SCA_IObject* sourceObj,const STR_String& propname,const STR_String& expr,int acttype) +SCA_PropertyActuator::SCA_PropertyActuator(SCA_IObject* gameobj,SCA_IObject* sourceObj,const std::string& propname,const std::string& expr,int acttype) : SCA_IActuator(gameobj, KX_ACT_PROPERTY), m_type(acttype), m_propname(propname), @@ -285,7 +285,7 @@ PyAttributeDef SCA_PropertyActuator::Attributes[] = { KX_PYATTRIBUTE_STRING_RW_CHECK("propName",0,MAX_PROP_NAME,false,SCA_PropertyActuator,m_propname,CheckProperty), KX_PYATTRIBUTE_STRING_RW("value",0,100,false,SCA_PropertyActuator,m_exprtxt), KX_PYATTRIBUTE_INT_RW("mode", KX_ACT_PROP_NODEF+1, KX_ACT_PROP_MAX-1, false, SCA_PropertyActuator, m_type), /* ATTR_TODO add constents to game logic dict */ - { NULL } //Sentinel + KX_PYATTRIBUTE_NULL //Sentinel }; #endif diff --git a/source/gameengine/GameLogic/SCA_PropertyActuator.h b/source/gameengine/GameLogic/SCA_PropertyActuator.h index afad42ea0b5b..46342461d187 100644 --- a/source/gameengine/GameLogic/SCA_PropertyActuator.h +++ b/source/gameengine/GameLogic/SCA_PropertyActuator.h @@ -52,8 +52,8 @@ class SCA_PropertyActuator : public SCA_IActuator bool isValid(KX_ACT_PROP_MODE mode); int m_type; - STR_String m_propname; - STR_String m_exprtxt; + std::string m_propname; + std::string m_exprtxt; SCA_IObject* m_sourceObj; // for copy property actuator public: @@ -63,8 +63,8 @@ class SCA_PropertyActuator : public SCA_IActuator SCA_PropertyActuator( SCA_IObject* gameobj, SCA_IObject* sourceObj, - const STR_String& propname, - const STR_String& expr, + const std::string& propname, + const std::string& expr, int acttype); diff --git a/source/gameengine/GameLogic/SCA_PropertySensor.cpp b/source/gameengine/GameLogic/SCA_PropertySensor.cpp index 073193db99aa..6272f30d91e5 100644 --- a/source/gameengine/GameLogic/SCA_PropertySensor.cpp +++ b/source/gameengine/GameLogic/SCA_PropertySensor.cpp @@ -47,11 +47,13 @@ #include "EXP_FloatValue.h" #include +#include + SCA_PropertySensor::SCA_PropertySensor(SCA_EventManager* eventmgr, SCA_IObject* gameobj, - const STR_String& propname, - const STR_String& propval, - const STR_String& propmaxval, + const std::string& propname, + const std::string& propval, + const std::string& propmaxval, KX_PROPSENSOR_TYPE checktype) : SCA_ISensor(gameobj,eventmgr), m_checktype(checktype), @@ -139,12 +141,12 @@ bool SCA_PropertySensor::CheckPropertyCondition() CValue* orgprop = GetParent()->FindIdentifier(m_checkpropname); if (!orgprop->IsError()) { - const STR_String& testprop = orgprop->GetText(); + const std::string& testprop = orgprop->GetText(); // Force strings to upper case, to avoid confusion in // bool tests. It's stupid the prop's identity is lost // on the way here... if ((testprop == CBoolValue::sTrueString) || (testprop == CBoolValue::sFalseString)) { - m_checkpropval.Upper(); + boost::to_upper(m_checkpropval); } result = (testprop == m_checkpropval); @@ -152,13 +154,8 @@ bool SCA_PropertySensor::CheckPropertyCondition() * this could be made into a generic Value class function for comparing values with a string. */ if (result==false && (orgprop->GetValueType() == VALUE_FLOAT_TYPE)) { - float f; - if (sscanf(m_checkpropval.ReadPtr(), "%f", &f) == 1) { - result = (f == ((CFloatValue *)orgprop)->GetFloat()); - } - else { - /* error */ - } + float f = std::stof(m_checkpropval); + result = (f == ((CFloatValue *)orgprop)->GetFloat()); } /* end patch */ } @@ -179,12 +176,12 @@ bool SCA_PropertySensor::CheckPropertyCondition() CValue* orgprop = GetParent()->FindIdentifier(m_checkpropname); if (!orgprop->IsError()) { - const float min = m_checkpropval.ToFloat(); - const float max = m_checkpropmaxval.ToFloat(); + const float min = std::stof(m_checkpropval); + const float max = std::stof(m_checkpropmaxval); float val; if (orgprop->GetValueType() == VALUE_STRING_TYPE) { - val = orgprop->GetText().ToFloat(); + val = std::stof(orgprop->GetText()); } else { val = orgprop->GetNumber(); @@ -220,11 +217,11 @@ bool SCA_PropertySensor::CheckPropertyCondition() CValue* orgprop = GetParent()->FindIdentifier(m_checkpropname); if (!orgprop->IsError()) { - const float ref = m_checkpropval.ToFloat(); + const float ref = std::stof(m_checkpropval); float val; if (orgprop->GetValueType() == VALUE_STRING_TYPE) { - val = orgprop->GetText().ToFloat(); + val = std::stof(orgprop->GetText()); } else { val = orgprop->GetNumber(); @@ -253,7 +250,7 @@ bool SCA_PropertySensor::CheckPropertyCondition() return result; } -CValue* SCA_PropertySensor::FindIdentifier(const STR_String& identifiername) +CValue* SCA_PropertySensor::FindIdentifier(const std::string& identifiername) { return GetParent()->FindIdentifier(identifiername); } @@ -307,7 +304,7 @@ PyAttributeDef SCA_PropertySensor::Attributes[] = { KX_PYATTRIBUTE_STRING_RW_CHECK("value",0,100,false,SCA_PropertySensor,m_checkpropval,validValueForProperty), KX_PYATTRIBUTE_STRING_RW_CHECK("min",0,100,false,SCA_PropertySensor,m_checkpropval,validValueForProperty), KX_PYATTRIBUTE_STRING_RW_CHECK("max",0,100,false,SCA_PropertySensor,m_checkpropmaxval,validValueForProperty), - { NULL } //Sentinel + KX_PYATTRIBUTE_NULL //Sentinel }; #endif // WITH_PYTHON diff --git a/source/gameengine/GameLogic/SCA_PropertySensor.h b/source/gameengine/GameLogic/SCA_PropertySensor.h index f9cfb5fb1d29..c2ece332fe7b 100644 --- a/source/gameengine/GameLogic/SCA_PropertySensor.h +++ b/source/gameengine/GameLogic/SCA_PropertySensor.h @@ -40,10 +40,10 @@ class SCA_PropertySensor : public SCA_ISensor Py_Header //class CExpression* m_rightexpr; int m_checktype; - STR_String m_checkpropval; - STR_String m_checkpropmaxval; - STR_String m_checkpropname; - STR_String m_previoustext; + std::string m_checkpropval; + std::string m_checkpropmaxval; + std::string m_checkpropname; + std::string m_previoustext; bool m_lastresult; bool m_recentresult; @@ -62,13 +62,13 @@ class SCA_PropertySensor : public SCA_ISensor KX_PROPSENSOR_MAX }; - const STR_String S_KX_PROPSENSOR_EQ_STRING; + const std::string S_KX_PROPSENSOR_EQ_STRING; SCA_PropertySensor(class SCA_EventManager* eventmgr, SCA_IObject* gameobj, - const STR_String& propname, - const STR_String& propval, - const STR_String& propmaxval, + const std::string& propname, + const std::string& propval, + const std::string& propmaxval, KX_PROPSENSOR_TYPE checktype); virtual ~SCA_PropertySensor(); @@ -78,7 +78,7 @@ class SCA_PropertySensor : public SCA_ISensor virtual bool Evaluate(); virtual bool IsPositiveTrigger(); - virtual CValue* FindIdentifier(const STR_String& identifiername); + virtual CValue* FindIdentifier(const std::string& identifiername); #ifdef WITH_PYTHON diff --git a/source/gameengine/GameLogic/SCA_PythonController.cpp b/source/gameengine/GameLogic/SCA_PythonController.cpp index d6f18ade59ff..c69d624fcf3d 100644 --- a/source/gameengine/GameLogic/SCA_PythonController.cpp +++ b/source/gameengine/GameLogic/SCA_PythonController.cpp @@ -117,7 +117,7 @@ CValue* SCA_PythonController::GetReplica() -void SCA_PythonController::SetScriptText(const STR_String& text) +void SCA_PythonController::SetScriptText(const std::string& text) { m_scriptText = text; m_bModified = true; @@ -125,7 +125,7 @@ void SCA_PythonController::SetScriptText(const STR_String& text) -void SCA_PythonController::SetScriptName(const STR_String& name) +void SCA_PythonController::SetScriptName(const std::string& name) { m_scriptName = name; } @@ -143,7 +143,7 @@ void SCA_PythonController::SetNamespace(PyObject* pythondictionary) /* Without __file__ set the sys.argv[0] is used for the filename * which ends up with lines from the blender binary being printed in the console */ - PyObject *value = PyUnicode_From_STR_String(m_scriptName); + PyObject *value = PyUnicode_FromStdString(m_scriptName); PyDict_SetItemString(m_pythondictionary, "__file__", value); Py_DECREF(value); @@ -240,7 +240,7 @@ PyMethodDef SCA_PythonController::Methods[] = { PyAttributeDef SCA_PythonController::Attributes[] = { KX_PYATTRIBUTE_RW_FUNCTION("script", SCA_PythonController, pyattr_get_script, pyattr_set_script), KX_PYATTRIBUTE_INT_RO("mode", SCA_PythonController, m_mode), - { NULL } //Sentinel + KX_PYATTRIBUTE_NULL //Sentinel }; void SCA_PythonController::ErrorPrint(const char *error_msg) @@ -271,7 +271,7 @@ bool SCA_PythonController::Compile() } // recompile the scripttext into bytecode - m_bytecode = Py_CompileString(m_scriptText.Ptr(), m_scriptName.Ptr(), Py_file_input); + m_bytecode = Py_CompileString(m_scriptText.c_str(), m_scriptName.c_str(), Py_file_input); if (m_bytecode) { return true; @@ -289,22 +289,22 @@ bool SCA_PythonController::Import() Py_XDECREF(m_function); m_function= NULL; - STR_String mod_path_str= m_scriptText; /* just for storage, use C style string access */ - char *mod_path= mod_path_str.Ptr(); - char *function_string; + std::string mod_path = m_scriptText; /* just for storage, use C style string access */ + std::string function_string; - function_string= strrchr(mod_path, '.'); + const int pos = mod_path.rfind('.'); + if (pos != std::string::npos) { + function_string = mod_path.substr(pos + 1); + mod_path = mod_path.substr(0, pos); + } - if (function_string == NULL) { + if (function_string.empty()) { CM_LogicBrickError(this, "python module name formatting expected 'SomeModule.Func', got '" << m_scriptText << "'"); return false; } - *function_string= '\0'; - function_string++; - // Import the module and print an error if it's not found - PyObject *mod = PyImport_ImportModule(mod_path); + PyObject *mod = PyImport_ImportModule(mod_path.c_str()); if (mod == NULL) { ErrorPrint("Python module can't be imported"); @@ -320,7 +320,7 @@ bool SCA_PythonController::Import() } // Get the function object - m_function = PyObject_GetAttrString(mod, function_string); + m_function = PyObject_GetAttrString(mod, function_string.c_str()); // DECREF the module as we don't need it anymore Py_DECREF(mod); @@ -476,7 +476,7 @@ PyObject *SCA_PythonController::pyattr_get_script(void *self_v, const KX_PYATTRI // static_cast(dynamic_cast(obj)) - static_cast(obj) SCA_PythonController* self = static_cast(self_v); - return PyUnicode_From_STR_String(self->m_scriptText); + return PyUnicode_FromStdString(self->m_scriptText); } diff --git a/source/gameengine/GameLogic/SCA_PythonController.h b/source/gameengine/GameLogic/SCA_PythonController.h index 11241da9117c..45569243a9e2 100644 --- a/source/gameengine/GameLogic/SCA_PythonController.h +++ b/source/gameengine/GameLogic/SCA_PythonController.h @@ -54,8 +54,8 @@ class SCA_PythonController : public SCA_IController protected: - STR_String m_scriptText; - STR_String m_scriptName; + std::string m_scriptText; + std::string m_scriptName; #ifdef WITH_PYTHON PyObject* m_pythondictionary; /* for SCA_PYEXEC_SCRIPT only */ PyObject* m_pythonfunction; /* for SCA_PYEXEC_MODULE only */ @@ -82,8 +82,8 @@ class SCA_PythonController : public SCA_IController virtual CValue* GetReplica(); virtual void Trigger(class SCA_LogicManager* logicmgr); - void SetScriptText(const STR_String& text); - void SetScriptName(const STR_String& name); + void SetScriptText(const std::string& text); + void SetScriptName(const std::string& name); #ifdef WITH_PYTHON void SetNamespace(PyObject* pythondictionary); #endif diff --git a/source/gameengine/GameLogic/SCA_PythonJoystick.cpp b/source/gameengine/GameLogic/SCA_PythonJoystick.cpp index 87f26826417b..bf1bc4a06473 100644 --- a/source/gameengine/GameLogic/SCA_PythonJoystick.cpp +++ b/source/gameengine/GameLogic/SCA_PythonJoystick.cpp @@ -60,7 +60,7 @@ SCA_PythonJoystick::~SCA_PythonJoystick() /* ------------------------------------------------------------------------- */ PyObject* SCA_PythonJoystick::py_repr(void) { - return PyUnicode_FromString(m_joystick->GetName()); + return PyUnicode_FromStdString(m_joystick->GetName()); } @@ -99,17 +99,19 @@ PyAttributeDef SCA_PythonJoystick::Attributes[] = { KX_PYATTRIBUTE_RO_FUNCTION("hatValues", SCA_PythonJoystick, pyattr_get_hat_values), KX_PYATTRIBUTE_RO_FUNCTION("axisValues", SCA_PythonJoystick, pyattr_get_axis_values), KX_PYATTRIBUTE_RO_FUNCTION("name", SCA_PythonJoystick, pyattr_get_name), - { NULL } //Sentinel + KX_PYATTRIBUTE_NULL //Sentinel }; // Use one function for numAxis, numButtons, and numHats PyObject* SCA_PythonJoystick::pyattr_get_num_x(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - if (strcmp(attrdef->m_name, "numButtons") == 0) + if (attrdef->m_name == "numButtons") { return PyLong_FromLong(JOYBUT_MAX); - else if (strcmp(attrdef->m_name, "numAxis") == 0) + } + else if (attrdef->m_name == "numAxis") { return PyLong_FromLong(JOYAXIS_MAX); - else if (strcmp(attrdef->m_name, "numHats") == 0) { + } + else if (attrdef->m_name == "numHats") { ShowDeprecationWarning("SCA_PythonJoystick.numHats", "SCA_PythonJoystick.numButtons"); return PyLong_FromLong(0); } @@ -173,6 +175,6 @@ PyObject* SCA_PythonJoystick::pyattr_get_name(void *self_v, const KX_PYATTRIBUTE { SCA_PythonJoystick* self = static_cast(self_v); - return PyUnicode_FromString(self->m_joystick->GetName()); + return PyUnicode_FromStdString(self->m_joystick->GetName()); } #endif diff --git a/source/gameengine/GameLogic/SCA_PythonKeyboard.cpp b/source/gameengine/GameLogic/SCA_PythonKeyboard.cpp index 1c1e3bb34f7d..c1305c77069a 100644 --- a/source/gameengine/GameLogic/SCA_PythonKeyboard.cpp +++ b/source/gameengine/GameLogic/SCA_PythonKeyboard.cpp @@ -109,7 +109,7 @@ PyAttributeDef SCA_PythonKeyboard::Attributes[] = { KX_PYATTRIBUTE_RO_FUNCTION("active_events", SCA_PythonKeyboard, pyattr_get_active_events), KX_PYATTRIBUTE_RO_FUNCTION("activeInputs", SCA_PythonKeyboard, pyattr_get_active_inputs), KX_PYATTRIBUTE_RO_FUNCTION("text", SCA_PythonKeyboard, pyattr_get_text), - { NULL } //Sentinel + KX_PYATTRIBUTE_NULL //Sentinel }; PyObject *SCA_PythonKeyboard::pyattr_get_events(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) @@ -219,7 +219,7 @@ PyObject *SCA_PythonKeyboard::pyattr_get_text(void *self_v, const KX_PYATTRIBUTE { SCA_PythonKeyboard *self = (SCA_PythonKeyboard *)self_v; - return PyUnicode_FromWideChar(self->m_keyboard->GetText().data(), self->m_keyboard->GetText().size()); + return PyUnicode_FromWideChar(self->m_keyboard->GetText().c_str(), self->m_keyboard->GetText().size()); } #endif diff --git a/source/gameengine/GameLogic/SCA_PythonMouse.cpp b/source/gameengine/GameLogic/SCA_PythonMouse.cpp index 6969d223d8b9..74684e73601e 100644 --- a/source/gameengine/GameLogic/SCA_PythonMouse.cpp +++ b/source/gameengine/GameLogic/SCA_PythonMouse.cpp @@ -91,7 +91,7 @@ PyAttributeDef SCA_PythonMouse::Attributes[] = { KX_PYATTRIBUTE_RO_FUNCTION("activeInputs", SCA_PythonMouse, pyattr_get_active_inputs), KX_PYATTRIBUTE_RW_FUNCTION("position", SCA_PythonMouse, pyattr_get_position, pyattr_set_position), KX_PYATTRIBUTE_RW_FUNCTION("visible", SCA_PythonMouse, pyattr_get_visible, pyattr_set_visible), - { NULL } //Sentinel + KX_PYATTRIBUTE_NULL //Sentinel }; PyObject *SCA_PythonMouse::pyattr_get_events(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) diff --git a/source/gameengine/GameLogic/SCA_RandomActuator.cpp b/source/gameengine/GameLogic/SCA_RandomActuator.cpp index 391780e028ee..c10386d399d7 100644 --- a/source/gameengine/GameLogic/SCA_RandomActuator.cpp +++ b/source/gameengine/GameLogic/SCA_RandomActuator.cpp @@ -53,7 +53,7 @@ SCA_RandomActuator::SCA_RandomActuator(SCA_IObject *gameobj, SCA_RandomActuator::KX_RANDOMACT_MODE mode, float para1, float para2, - const STR_String &propName) + const std::string &propName) : SCA_IActuator(gameobj, KX_ACT_RANDOM), m_propname(propName), m_parameter1(para1), @@ -350,7 +350,7 @@ PyAttributeDef SCA_RandomActuator::Attributes[] = { KX_PYATTRIBUTE_ENUM_RO("distribution",SCA_RandomActuator,m_distribution), KX_PYATTRIBUTE_STRING_RW_CHECK("propName",0,MAX_PROP_NAME,false,SCA_RandomActuator,m_propname,CheckProperty), KX_PYATTRIBUTE_RW_FUNCTION("seed",SCA_RandomActuator,pyattr_get_seed,pyattr_set_seed), - { NULL } //Sentinel + KX_PYATTRIBUTE_NULL //Sentinel }; PyObject *SCA_RandomActuator::pyattr_get_seed(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef) diff --git a/source/gameengine/GameLogic/SCA_RandomActuator.h b/source/gameengine/GameLogic/SCA_RandomActuator.h index 32b29fc4f43e..d39e0ce8e1b5 100644 --- a/source/gameengine/GameLogic/SCA_RandomActuator.h +++ b/source/gameengine/GameLogic/SCA_RandomActuator.h @@ -40,7 +40,7 @@ class SCA_RandomActuator : public SCA_IActuator { Py_Header /** Property to assign to */ - STR_String m_propname; + std::string m_propname; /** First parameter. The meaning of the parameters depends on the * distribution */ @@ -85,7 +85,7 @@ class SCA_RandomActuator : public SCA_IActuator KX_RANDOMACT_MODE mode, float para1, float para2, - const STR_String &propName); + const std::string &propName); virtual ~SCA_RandomActuator(); virtual bool Update(); diff --git a/source/gameengine/GameLogic/SCA_RandomSensor.cpp b/source/gameengine/GameLogic/SCA_RandomSensor.cpp index d1da21199f0d..a464a9a2035f 100644 --- a/source/gameengine/GameLogic/SCA_RandomSensor.cpp +++ b/source/gameengine/GameLogic/SCA_RandomSensor.cpp @@ -161,7 +161,7 @@ PyMethodDef SCA_RandomSensor::Methods[] = { PyAttributeDef SCA_RandomSensor::Attributes[] = { KX_PYATTRIBUTE_BOOL_RO("lastDraw",SCA_RandomSensor,m_lastdraw), KX_PYATTRIBUTE_RW_FUNCTION("seed", SCA_RandomSensor, pyattr_get_seed, pyattr_set_seed), - {NULL} //Sentinel + KX_PYATTRIBUTE_NULL //Sentinel }; PyObject *SCA_RandomSensor::pyattr_get_seed(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) diff --git a/source/gameengine/GameLogic/SCA_VibrationActuator.cpp b/source/gameengine/GameLogic/SCA_VibrationActuator.cpp index 1cc251e31584..f36cd7529510 100644 --- a/source/gameengine/GameLogic/SCA_VibrationActuator.cpp +++ b/source/gameengine/GameLogic/SCA_VibrationActuator.cpp @@ -113,7 +113,7 @@ PyAttributeDef SCA_VibrationActuator::Attributes[] = { KX_PYATTRIBUTE_INT_RW("duration", 0, INT_MAX, true, SCA_VibrationActuator, m_duration), KX_PYATTRIBUTE_INT_RW("joyindex", 0, 7, true, SCA_VibrationActuator, m_joyindex), KX_PYATTRIBUTE_FLOAT_RW("strength", 0.0, 1.0, SCA_VibrationActuator, m_strength), - { NULL } //Sentinel + KX_PYATTRIBUTE_NULL //Sentinel }; #endif // WITH_PYTHON diff --git a/source/gameengine/GameLogic/SCA_XNORController.cpp b/source/gameengine/GameLogic/SCA_XNORController.cpp index 24a950801c70..6a000ae5fd65 100644 --- a/source/gameengine/GameLogic/SCA_XNORController.cpp +++ b/source/gameengine/GameLogic/SCA_XNORController.cpp @@ -129,7 +129,7 @@ PyMethodDef SCA_XNORController::Methods[] = { }; PyAttributeDef SCA_XNORController::Attributes[] = { - { NULL } //Sentinel + KX_PYATTRIBUTE_NULL //Sentinel }; #endif // WITH_PYTHON diff --git a/source/gameengine/GameLogic/SCA_XORController.cpp b/source/gameengine/GameLogic/SCA_XORController.cpp index c658b6933e7f..ae088c6331d7 100644 --- a/source/gameengine/GameLogic/SCA_XORController.cpp +++ b/source/gameengine/GameLogic/SCA_XORController.cpp @@ -129,7 +129,7 @@ PyMethodDef SCA_XORController::Methods[] = { }; PyAttributeDef SCA_XORController::Attributes[] = { - { NULL } //Sentinel + KX_PYATTRIBUTE_NULL //Sentinel }; #endif // WITH_PYTHON diff --git a/source/gameengine/GamePlayer/GPG_Canvas.cpp b/source/gameengine/GamePlayer/GPG_Canvas.cpp index 4c5f94e2bbf0..3d2a17313a45 100644 --- a/source/gameengine/GamePlayer/GPG_Canvas.cpp +++ b/source/gameengine/GamePlayer/GPG_Canvas.cpp @@ -145,7 +145,7 @@ const int *GPG_Canvas::GetViewPort() return m_viewport; } -void GPG_Canvas::MakeScreenShot(const char *filename) +void GPG_Canvas::MakeScreenShot(const std::string& filename) { // copy image data unsigned int dumpsx = GetWidth(); @@ -164,8 +164,8 @@ void GPG_Canvas::MakeScreenShot(const char *filename) // create file path char path[FILE_MAX]; - BLI_strncpy(path, filename, FILE_MAX); - BLI_path_abs(path, KX_GetMainPath().ReadPtr()); + BLI_strncpy(path, filename.c_str(), FILE_MAX); + BLI_path_abs(path, KX_GetMainPath().c_str()); /* save_screenshot() frees dumprect and im_format */ save_screenshot(path, dumpsx, dumpsy, pixels, im_format); diff --git a/source/gameengine/GamePlayer/GPG_Canvas.h b/source/gameengine/GamePlayer/GPG_Canvas.h index 544cdbf0bcea..1a8dfc78d3e9 100644 --- a/source/gameengine/GamePlayer/GPG_Canvas.h +++ b/source/gameengine/GamePlayer/GPG_Canvas.h @@ -81,7 +81,7 @@ class GPG_Canvas : public RAS_ICanvas virtual void UpdateViewPort(int x1, int y1, int x2, int y2); virtual const int *GetViewPort(); - virtual void MakeScreenShot(const char *filename); + virtual void MakeScreenShot(const std::string& filename); virtual void Init(); virtual void SetMousePosition(int x, int y); diff --git a/source/gameengine/GamePlayer/GPG_ghost.cpp b/source/gameengine/GamePlayer/GPG_ghost.cpp index 619bdb2c0d44..f0aa693f556a 100644 --- a/source/gameengine/GamePlayer/GPG_ghost.cpp +++ b/source/gameengine/GamePlayer/GPG_ghost.cpp @@ -116,6 +116,8 @@ extern "C" # include "sdlew.h" #endif +#include + #include "CM_Message.h" const int kMinWindowWidth = 100; @@ -255,7 +257,7 @@ static GHOST_IWindow *startScreenSaverPreview( { int windowWidth = rc.right - rc.left; int windowHeight = rc.bottom - rc.top; - STR_String title = ""; + std::string title = ""; GHOST_GLSettings glSettings = {0}; if (stereoVisual) { @@ -352,7 +354,7 @@ static GHOST_IWindow *startScreenSaverFullScreen( static GHOST_IWindow *startWindow( GHOST_ISystem *system, - STR_String& title, + std::string& title, int windowLeft, int windowTop, int windowWidth, @@ -362,7 +364,7 @@ static GHOST_IWindow *startWindow( { GHOST_GLSettings glSettings = {0}; // Create the main window - //STR_String title ("Blender Player - GHOST"); + //std::string title ("Blender Player - GHOST"); if (stereoVisual) glSettings.flags |= GHOST_glStereoVisual; if (alphaBackground) @@ -386,7 +388,7 @@ static GHOST_IWindow *startWindow( static GHOST_IWindow *startEmbeddedWindow( GHOST_ISystem *system, - STR_String& title, + std::string& title, const GHOST_TEmbedderWindowID parentWindow, const bool stereoVisual, const int alphaBackground) @@ -412,16 +414,15 @@ static GHOST_IWindow *startEmbeddedWindow( return window; } -static void usage(const char* program, bool isBlenderPlayer) +static void usage(const std::string& program, bool isBlenderPlayer) { - const char * consoleoption; - const char * example_filename = ""; - const char * example_pathname = ""; + std::string example_filename = ""; + std::string example_pathname = ""; #ifdef _WIN32 - consoleoption = "[-c] "; + const std::string consoleoption = "[-c] "; #else - consoleoption = ""; + const std::string consoleoption = ""; #endif if (isBlenderPlayer) { @@ -1041,7 +1042,7 @@ int main( // of scope before GHOST_ISystem::disposeSystem() is called. { int exitcode = KX_EXIT_REQUEST_NO_REQUEST; - STR_String exitstring = ""; + std::string exitstring = ""; bool firstTimeRunning = true; char filename[FILE_MAX]; char pathname[FILE_MAX]; @@ -1070,7 +1071,7 @@ int main( char basedpath[FILE_MAX]; // base the actuator filename relative to the last file - BLI_strncpy(basedpath, exitstring.Ptr(), sizeof(basedpath)); + BLI_strncpy(basedpath, exitstring.c_str(), sizeof(basedpath)); BLI_path_abs(basedpath, pathname); bfd = load_game_data(basedpath); @@ -1230,19 +1231,21 @@ int main( } #endif // Strip the path so that we have the name of the game file - STR_String path = titlename; + std::string path = titlename; + std::vector parts; #ifndef WIN32 - std::vector parts = path.Explode('/'); + boost::split(parts, path, boost::is_any_of("/")); #else // WIN32 - std::vector parts = path.Explode('\\'); + boost::split(parts, path, boost::is_any_of("\\")); #endif // WIN32 - STR_String title; + std::string title; if (parts.size()) { - title = parts[parts.size()-1]; - parts = title.Explode('.'); - if (parts.size() > 1) + title = parts[parts.size() - 1]; + std::vector sublastparts; + boost::split(sublastparts, title, boost::is_any_of(".")); + if (sublastparts.size() > 1) { - title = parts[0]; + title = sublastparts[0]; } } else { diff --git a/source/gameengine/Ketsji/BL_Action.cpp b/source/gameengine/Ketsji/BL_Action.cpp index 52b27c2f9656..6f0ec5dfa498 100644 --- a/source/gameengine/Ketsji/BL_Action.cpp +++ b/source/gameengine/Ketsji/BL_Action.cpp @@ -109,7 +109,7 @@ void BL_Action::ClearControllerList() m_sg_contr_list.clear(); } -bool BL_Action::Play(const char* name, +bool BL_Action::Play(const std::string& name, float start, float end, short priority, @@ -292,7 +292,7 @@ float BL_Action::GetFrame() return m_localframe; } -const char *BL_Action::GetName() +const std::string BL_Action::GetName() { if (m_action != NULL) { return m_action->id.name + 2; @@ -300,8 +300,6 @@ const char *BL_Action::GetName() else { return ""; } - - } void BL_Action::SetFrame(float frame) diff --git a/source/gameengine/Ketsji/BL_Action.h b/source/gameengine/Ketsji/BL_Action.h index dbf4b225b4d3..2a8c33fb6f39 100644 --- a/source/gameengine/Ketsji/BL_Action.h +++ b/source/gameengine/Ketsji/BL_Action.h @@ -27,7 +27,7 @@ #ifndef __BL_ACTION_H__ #define __BL_ACTION_H__ - +#include #include #ifdef WITH_CXX_GUARDEDALLOC @@ -90,7 +90,7 @@ class BL_Action /** * Play an action */ - bool Play(const char* name, + bool Play(const std::string& name, float start, float end, short priority, @@ -118,7 +118,7 @@ class BL_Action // Accessors float GetFrame(); - const char *GetName(); + const std::string GetName(); struct bAction *GetAction(); diff --git a/source/gameengine/Ketsji/BL_ActionManager.cpp b/source/gameengine/Ketsji/BL_ActionManager.cpp index 458d6f86c427..107252753fa2 100644 --- a/source/gameengine/Ketsji/BL_ActionManager.cpp +++ b/source/gameengine/Ketsji/BL_ActionManager.cpp @@ -59,7 +59,7 @@ float BL_ActionManager::GetActionFrame(short layer) return action ? action->GetFrame() : 0.f; } -const char *BL_ActionManager::GetActionName(short layer) +const std::string BL_ActionManager::GetActionName(short layer) { BL_Action *action = GetAction(layer); return action ? action->GetName() : ""; @@ -93,7 +93,7 @@ void BL_ActionManager::SetTimes(short layer, float start, float end) if (action) action->SetTimes(start, end); } -bool BL_ActionManager::PlayAction(const char* name, +bool BL_ActionManager::PlayAction(const std::string& name, float start, float end, short layer, diff --git a/source/gameengine/Ketsji/BL_ActionManager.h b/source/gameengine/Ketsji/BL_ActionManager.h index ef4b7ee0c744..9c0a5706c751 100644 --- a/source/gameengine/Ketsji/BL_ActionManager.h +++ b/source/gameengine/Ketsji/BL_ActionManager.h @@ -60,7 +60,7 @@ class BL_ActionManager BL_ActionManager(class KX_GameObject* obj); ~BL_ActionManager(); - bool PlayAction(const char* name, + bool PlayAction(const std::string& name, float start, float end, short layer=0, @@ -79,7 +79,7 @@ class BL_ActionManager /** * Gets the name of the current action */ - const char *GetActionName(short layer); + const std::string GetActionName(short layer); /** * Sets the current frame of an action diff --git a/source/gameengine/Ketsji/BL_BlenderShader.h b/source/gameengine/Ketsji/BL_BlenderShader.h index aab904f00bff..04789180b07f 100644 --- a/source/gameengine/Ketsji/BL_BlenderShader.h +++ b/source/gameengine/Ketsji/BL_BlenderShader.h @@ -35,7 +35,7 @@ #include "RAS_IRasterizer.h" #include "RAS_MeshObject.h" #include "RAS_Texture.h" // for MaxUnits -#include "STR_String.h" +#include struct Material; struct Scene; diff --git a/source/gameengine/Ketsji/BL_Shader.cpp b/source/gameengine/Ketsji/BL_Shader.cpp index 63d945126662..146ed0b10461 100644 --- a/source/gameengine/Ketsji/BL_Shader.cpp +++ b/source/gameengine/Ketsji/BL_Shader.cpp @@ -130,7 +130,7 @@ PyAttributeDef BL_Shader::Attributes[] = { KX_PYATTRIBUTE_RW_FUNCTION("enabled", BL_Shader, pyattr_get_enabled, pyattr_set_enabled), KX_PYATTRIBUTE_RW_FUNCTION("bindCallbacks", BL_Shader, pyattr_get_callbacks, pyattr_set_callbacks), KX_PYATTRIBUTE_RW_FUNCTION("objectCallbacks", BL_Shader, pyattr_get_callbacks, pyattr_set_callbacks), - {NULL} //Sentinel + KX_PYATTRIBUTE_NULL //Sentinel }; PyTypeObject BL_Shader::Type = { @@ -174,7 +174,7 @@ int BL_Shader::pyattr_set_enabled(void *self_v, const KX_PYATTRIBUTE_DEF *attrde return PY_SET_ATTR_SUCCESS; } -static std::map callbacksTable = { +static std::map callbacksTable = { {"bindCallbacks", BL_Shader::CALLBACKS_BIND}, {"objectCallbacks", BL_Shader::CALLBACKS_OBJECT} }; @@ -191,7 +191,7 @@ int BL_Shader::pyattr_set_callbacks(void *self_v, const KX_PYATTRIBUTE_DEF *attr { BL_Shader *self = static_cast(self_v); if (!PyList_CheckExact(value)) { - PyErr_Format(PyExc_AttributeError, "shader.%s = bool: BL_Shader, expected a list", attrdef->m_name); + PyErr_Format(PyExc_AttributeError, "shader.%s = bool: BL_Shader, expected a list", attrdef->m_name.c_str()); return PY_SET_ATTR_FAIL; } @@ -210,8 +210,8 @@ KX_PYMETHODDEF_DOC(BL_Shader, setSource, " setSource(vertexProgram, fragmentProg int apply = 0; if (PyArg_ParseTuple(args, "ssi:setSource", &v, &f, &apply)) { - m_progs[VERTEX_PROGRAM] = STR_String(v); - m_progs[FRAGMENT_PROGRAM] = STR_String(f); + m_progs[VERTEX_PROGRAM] = std::string(v); + m_progs[FRAGMENT_PROGRAM] = std::string(f); m_progs[GEOMETRY_PROGRAM] = ""; if (LinkProgram()) { @@ -261,7 +261,7 @@ KX_PYMETHODDEF_DOC(BL_Shader, setSourceList, " setSourceList(sources, apply)") } } if (pyprog) { - m_progs[i] = STR_String(_PyUnicode_AsString(pyprog)); + m_progs[i] = std::string(_PyUnicode_AsString(pyprog)); } } @@ -295,12 +295,12 @@ KX_PYMETHODDEF_DOC(BL_Shader, isValid, "isValid()") KX_PYMETHODDEF_DOC(BL_Shader, getVertexProg, "getVertexProg( )") { - return PyUnicode_FromString(m_progs[VERTEX_PROGRAM].ReadPtr()); + return PyUnicode_FromStdString(m_progs[VERTEX_PROGRAM]); } KX_PYMETHODDEF_DOC(BL_Shader, getFragmentProg, "getFragmentProg( )") { - return PyUnicode_FromString(m_progs[FRAGMENT_PROGRAM].ReadPtr()); + return PyUnicode_FromStdString(m_progs[FRAGMENT_PROGRAM]); } KX_PYMETHODDEF_DOC(BL_Shader, validate, "validate()") diff --git a/source/gameengine/Ketsji/BL_Shader.h b/source/gameengine/Ketsji/BL_Shader.h index 4a9097fc3ebe..051d2bc16e79 100644 --- a/source/gameengine/Ketsji/BL_Shader.h +++ b/source/gameengine/Ketsji/BL_Shader.h @@ -48,7 +48,7 @@ class BL_Shader : public PyObjectPlus, public virtual RAS_Shader #ifdef WITH_PYTHON virtual PyObject *py_repr() { - return PyUnicode_FromFormat("BL_Shader\n\tvertex shader:%s\n\n\tfragment shader%s\n\n", m_progs[VERTEX_PROGRAM].ReadPtr(), m_progs[FRAGMENT_PROGRAM].ReadPtr()); + return PyUnicode_FromFormat("BL_Shader\n\tvertex shader:%s\n\n\tfragment shader%s\n\n", m_progs[VERTEX_PROGRAM].c_str(), m_progs[FRAGMENT_PROGRAM].c_str()); } static PyObject *pyattr_get_enabled(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); diff --git a/source/gameengine/Ketsji/BL_Texture.cpp b/source/gameengine/Ketsji/BL_Texture.cpp index 7e7ce483dd0c..535d3606b014 100644 --- a/source/gameengine/Ketsji/BL_Texture.cpp +++ b/source/gameengine/Ketsji/BL_Texture.cpp @@ -51,7 +51,7 @@ BL_Texture::BL_Texture(MTex *mtex) m_gpuTex = (ima ? GPU_texture_from_blender(ima, &iuser, gltextarget, false, 0.0, true) : NULL); // Initialize saved data. - m_name = STR_String(m_mtex->tex->id.name + 2); + m_name = std::string(m_mtex->tex->id.name + 2); m_savedData.colintensfac = m_mtex->difffac; m_savedData.colfac = m_mtex->colfac; m_savedData.alphafac = m_mtex->alphafac; @@ -202,7 +202,7 @@ unsigned int BL_Texture::swapTexture(unsigned int bindcode) } // stuff for cvalue related things -STR_String BL_Texture::GetName() +std::string BL_Texture::GetName() { return RAS_Texture::GetName(); } @@ -255,7 +255,7 @@ PyAttributeDef BL_Texture::Attributes[] = { KX_PYATTRIBUTE_RW_FUNCTION("uvRotation", BL_Texture, pyattr_get_uv_rotation, pyattr_set_uv_rotation), KX_PYATTRIBUTE_RW_FUNCTION("uvOffset", BL_Texture, pyattr_get_uv_offset, pyattr_set_uv_offset), KX_PYATTRIBUTE_RW_FUNCTION("uvSize", BL_Texture, pyattr_get_uv_size, pyattr_set_uv_size), - { NULL } //Sentinel + KX_PYATTRIBUTE_NULL //Sentinel }; PyObject *BL_Texture::pyattr_get_diffuse_intensity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) @@ -270,7 +270,7 @@ int BL_Texture::pyattr_set_diffuse_intensity(void *self_v, const KX_PYATTRIBUTE_ float val = PyFloat_AsDouble(value); if (val == -1 && PyErr_Occurred()) { - PyErr_Format(PyExc_AttributeError, "texture.%s = float: BL_Texture, expected a float", attrdef->m_name); + PyErr_Format(PyExc_AttributeError, "texture.%s = float: BL_Texture, expected a float", attrdef->m_name.c_str()); return PY_SET_ATTR_FAIL; } @@ -290,7 +290,7 @@ int BL_Texture::pyattr_set_diffuse_factor(void *self_v, const KX_PYATTRIBUTE_DEF float val = PyFloat_AsDouble(value); if (val == -1 && PyErr_Occurred()) { - PyErr_Format(PyExc_AttributeError, "texture.%s = float: BL_Texture, expected a float", attrdef->m_name); + PyErr_Format(PyExc_AttributeError, "texture.%s = float: BL_Texture, expected a float", attrdef->m_name.c_str()); return PY_SET_ATTR_FAIL; } @@ -310,7 +310,7 @@ int BL_Texture::pyattr_set_alpha(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef float val = PyFloat_AsDouble(value); if (val == -1 && PyErr_Occurred()) { - PyErr_Format(PyExc_AttributeError, "texture.%s = float: BL_Texture, expected a float", attrdef->m_name); + PyErr_Format(PyExc_AttributeError, "texture.%s = float: BL_Texture, expected a float", attrdef->m_name.c_str()); return PY_SET_ATTR_FAIL; } @@ -330,7 +330,7 @@ int BL_Texture::pyattr_set_specular_intensity(void *self_v, const KX_PYATTRIBUTE float val = PyFloat_AsDouble(value); if (val == -1 && PyErr_Occurred()) { - PyErr_Format(PyExc_AttributeError, "texture.%s = float: BL_Texture, expected a float", attrdef->m_name); + PyErr_Format(PyExc_AttributeError, "texture.%s = float: BL_Texture, expected a float", attrdef->m_name.c_str()); return PY_SET_ATTR_FAIL; } @@ -350,7 +350,7 @@ int BL_Texture::pyattr_set_specular_factor(void *self_v, const KX_PYATTRIBUTE_DE float val = PyFloat_AsDouble(value); if (val == -1 && PyErr_Occurred()) { - PyErr_Format(PyExc_AttributeError, "texture.%s = float: BL_Texture, expected a float", attrdef->m_name); + PyErr_Format(PyExc_AttributeError, "texture.%s = float: BL_Texture, expected a float", attrdef->m_name.c_str()); return PY_SET_ATTR_FAIL; } @@ -370,7 +370,7 @@ int BL_Texture::pyattr_set_hardness(void *self_v, const KX_PYATTRIBUTE_DEF *attr float val = PyFloat_AsDouble(value); if (val == -1 && PyErr_Occurred()) { - PyErr_Format(PyExc_AttributeError, "texture.%s = float: BL_Texture, expected a float", attrdef->m_name); + PyErr_Format(PyExc_AttributeError, "texture.%s = float: BL_Texture, expected a float", attrdef->m_name.c_str()); return PY_SET_ATTR_FAIL; } @@ -390,7 +390,7 @@ int BL_Texture::pyattr_set_emit(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, float val = PyFloat_AsDouble(value); if (val == -1 && PyErr_Occurred()) { - PyErr_Format(PyExc_AttributeError, "texture.%s = float: BL_Texture, expected a float", attrdef->m_name); + PyErr_Format(PyExc_AttributeError, "texture.%s = float: BL_Texture, expected a float", attrdef->m_name.c_str()); return PY_SET_ATTR_FAIL; } @@ -410,7 +410,7 @@ int BL_Texture::pyattr_set_mirror(void *self_v, const KX_PYATTRIBUTE_DEF *attrde float val = PyFloat_AsDouble(value); if (val == -1 && PyErr_Occurred()) { - PyErr_Format(PyExc_AttributeError, "texture.%s = float: BL_Texture, expected a float", attrdef->m_name); + PyErr_Format(PyExc_AttributeError, "texture.%s = float: BL_Texture, expected a float", attrdef->m_name.c_str()); return PY_SET_ATTR_FAIL; } @@ -430,7 +430,7 @@ int BL_Texture::pyattr_set_normal(void *self_v, const KX_PYATTRIBUTE_DEF *attrde float val = PyFloat_AsDouble(value); if (val == -1 && PyErr_Occurred()) { - PyErr_Format(PyExc_AttributeError, "texture.%s = float: BL_Texture, expected a float", attrdef->m_name); + PyErr_Format(PyExc_AttributeError, "texture.%s = float: BL_Texture, expected a float", attrdef->m_name.c_str()); return PY_SET_ATTR_FAIL; } @@ -450,7 +450,7 @@ int BL_Texture::pyattr_set_parallax_bump(void *self_v, const KX_PYATTRIBUTE_DEF float val = PyFloat_AsDouble(value); if (val == -1 && PyErr_Occurred()) { - PyErr_Format(PyExc_AttributeError, "texture.%s = float: BL_Texture, expected a float", attrdef->m_name); + PyErr_Format(PyExc_AttributeError, "texture.%s = float: BL_Texture, expected a float", attrdef->m_name.c_str()); return PY_SET_ATTR_FAIL; } @@ -470,7 +470,7 @@ int BL_Texture::pyattr_set_parallax_step(void *self_v, const KX_PYATTRIBUTE_DEF float val = PyFloat_AsDouble(value); if (val == -1 && PyErr_Occurred()) { - PyErr_Format(PyExc_AttributeError, "texture.%s = float: BL_Texture, expected a float", attrdef->m_name); + PyErr_Format(PyExc_AttributeError, "texture.%s = float: BL_Texture, expected a float", attrdef->m_name.c_str()); return PY_SET_ATTR_FAIL; } @@ -490,7 +490,7 @@ int BL_Texture::pyattr_set_lod_bias(void *self_v, const KX_PYATTRIBUTE_DEF *attr float val = PyFloat_AsDouble(value); if (val == -1 && PyErr_Occurred()) { - PyErr_Format(PyExc_AttributeError, "texture.%s = float: BL_Texture, expected a float", attrdef->m_name); + PyErr_Format(PyExc_AttributeError, "texture.%s = float: BL_Texture, expected a float", attrdef->m_name.c_str()); return PY_SET_ATTR_FAIL; } @@ -511,7 +511,7 @@ int BL_Texture::pyattr_set_bind_code(void *self_v, const KX_PYATTRIBUTE_DEF *att int val = PyLong_AsLong(value); if (val < 0 && PyErr_Occurred()) { - PyErr_Format(PyExc_AttributeError, "texture.%s = int: BL_Texture, expected a unsigned int", attrdef->m_name); + PyErr_Format(PyExc_AttributeError, "texture.%s = int: BL_Texture, expected a unsigned int", attrdef->m_name.c_str()); return PY_SET_ATTR_FAIL; } @@ -542,7 +542,7 @@ int BL_Texture::pyattr_set_ior(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, float val = PyFloat_AsDouble(value); if (val == -1 && PyErr_Occurred()) { - PyErr_Format(PyExc_AttributeError, "texture.%s = float: BL_Texture, expected a float", attrdef->m_name); + PyErr_Format(PyExc_AttributeError, "texture.%s = float: BL_Texture, expected a float", attrdef->m_name.c_str()); return PY_SET_ATTR_FAIL; } @@ -563,7 +563,7 @@ int BL_Texture::pyattr_set_refraction_ratio(void *self_v, const KX_PYATTRIBUTE_D float val = PyFloat_AsDouble(value); if (val == -1 && PyErr_Occurred()) { - PyErr_Format(PyExc_AttributeError, "texture.%s = float: BL_Texture, expected a float", attrdef->m_name); + PyErr_Format(PyExc_AttributeError, "texture.%s = float: BL_Texture, expected a float", attrdef->m_name.c_str()); return PY_SET_ATTR_FAIL; } CLAMP(val, 0.0, 1.0); @@ -583,7 +583,7 @@ int BL_Texture::pyattr_set_uv_rotation(void *self_v, const KX_PYATTRIBUTE_DEF *a float val = PyFloat_AsDouble(value); if (val == -1 && PyErr_Occurred()) { - PyErr_Format(PyExc_AttributeError, "texture.%s = float: BL_Texture, expected a float", attrdef->m_name); + PyErr_Format(PyExc_AttributeError, "texture.%s = float: BL_Texture, expected a float", attrdef->m_name.c_str()); return PY_SET_ATTR_FAIL; } self->GetMTex()->rot = val; diff --git a/source/gameengine/Ketsji/BL_Texture.h b/source/gameengine/Ketsji/BL_Texture.h index 1fc83d5cf143..30c309f020b5 100644 --- a/source/gameengine/Ketsji/BL_Texture.h +++ b/source/gameengine/Ketsji/BL_Texture.h @@ -67,7 +67,7 @@ class BL_Texture : public CValue, public RAS_Texture virtual ~BL_Texture(); // stuff for cvalue related things - virtual STR_String GetName(); + virtual std::string GetName(); virtual bool Ok() const; virtual bool IsCubeMap() const; diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp index d8db6d6e3e5b..03ade5b1cc23 100644 --- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp +++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp @@ -39,10 +39,10 @@ KX_NetworkMessageActuator::KX_NetworkMessageActuator( SCA_IObject *gameobj, // the actuator controlling object KX_NetworkMessageScene *networkscene, // needed for replication - const STR_String &toPropName, - const STR_String &subject, + const std::string &toPropName, + const std::string &subject, int bodyType, - const STR_String &body) + const std::string &body) :SCA_IActuator(gameobj, KX_ACT_MESSAGE), m_networkscene(networkscene), m_toPropName(toPropName), @@ -130,7 +130,7 @@ PyAttributeDef KX_NetworkMessageActuator::Attributes[] = { KX_PYATTRIBUTE_STRING_RW("subject", 0, 100, false, KX_NetworkMessageActuator, m_subject), KX_PYATTRIBUTE_BOOL_RW("usePropBody", KX_NetworkMessageActuator, m_bPropBody), KX_PYATTRIBUTE_STRING_RW("body", 0, 16384, false, KX_NetworkMessageActuator, m_body), - {NULL} //Sentinel + KX_PYATTRIBUTE_NULL //Sentinel }; #endif // WITH_PYTHON diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.h b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.h index d7f27292930e..9934c5d8e99b 100644 --- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.h +++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.h @@ -33,7 +33,7 @@ #ifndef __KX_NETWORKMESSAGEACTUATOR_H__ #define __KX_NETWORKMESSAGEACTUATOR_H__ -#include "STR_String.h" +#include #include "SCA_IActuator.h" class KX_NetworkMessageActuator : public SCA_IActuator @@ -41,19 +41,19 @@ class KX_NetworkMessageActuator : public SCA_IActuator Py_Header bool m_lastEvent; class KX_NetworkMessageScene *m_networkscene; // needed for replication - STR_String m_toPropName; - STR_String m_subject; + std::string m_toPropName; + std::string m_subject; bool m_bPropBody; - STR_String m_body; + std::string m_body; public: KX_NetworkMessageActuator( SCA_IObject *gameobj, KX_NetworkMessageScene *networkscene, - const STR_String &toPropName, - const STR_String &subject, + const std::string &toPropName, + const std::string &subject, int bodyType, - const STR_String &body); + const std::string &body); virtual ~KX_NetworkMessageActuator(); virtual bool Update(); diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageManager.cpp b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageManager.cpp index bb119c6ac51d..386e6063b875 100644 --- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageManager.cpp +++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageManager.cpp @@ -49,22 +49,22 @@ void KX_NetworkMessageManager::AddMessage(KX_NetworkMessageManager::Message mess m_messages[m_currentList][message.to][message.subject].push_back(message); } -const std::vector KX_NetworkMessageManager::GetMessages(STR_String to, STR_String subject) +const std::vector KX_NetworkMessageManager::GetMessages(std::string to, std::string subject) { std::vector messages; // look at messages without receiver. - std::map >& messagesNoReceiver = m_messages[1 - m_currentList][""]; - std::map >& messagesReceiver = m_messages[1 - m_currentList][to]; - if (subject.IsEmpty()) { + std::map >& messagesNoReceiver = m_messages[1 - m_currentList][""]; + std::map >& messagesReceiver = m_messages[1 - m_currentList][to]; + if (subject.empty()) { // Add all message without receiver and subject. - for (std::map >::iterator it = messagesNoReceiver.begin(), end = messagesNoReceiver.end(); + for (std::map >::iterator it = messagesNoReceiver.begin(), end = messagesNoReceiver.end(); it != end; ++it) { messages.insert(messages.end(), it->second.begin(), it->second.end()); } // Add all message with the given receiver and no subject. - for (std::map >::iterator it = messagesReceiver.begin(), end = messagesReceiver.end(); + for (std::map >::iterator it = messagesReceiver.begin(), end = messagesReceiver.end(); it != end; ++it) { messages.insert(messages.end(), it->second.begin(), it->second.end()); diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageManager.h b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageManager.h index d50fd5499e2e..78aaec2c3b4f 100644 --- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageManager.h +++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageManager.h @@ -35,7 +35,7 @@ conflicts with KX_NetworkMessageManager::SendMessage */ # undef SendMessage #endif -#include "STR_String.h" +#include #include #include @@ -47,13 +47,13 @@ class KX_NetworkMessageManager struct Message { /// Receiver object(s) name. - STR_String to; + std::string to; /// Sender game object. SCA_IObject *from; /// Message subject, used as filter. - STR_String subject; + std::string subject; /// Message body. - STR_String body; + std::string body; }; private: @@ -61,7 +61,7 @@ class KX_NetworkMessageManager * We use two lists, one handle sended message in the current frame and the other * is used for handle message sended in the last frame for sensors. */ - std::map > > m_messages[2]; + std::map > > m_messages[2]; /** Since we use two list for the current and last frame we have to switch of * current message list each frame. This value is only 0 or 1. @@ -80,7 +80,7 @@ class KX_NetworkMessageManager * \param to The object(s) name. * \param subject The message subject/filter. */ - const std::vector GetMessages(STR_String to, STR_String subject); + const std::vector GetMessages(std::string to, std::string subject); /// Clear all messages void ClearMessages(); diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageScene.cpp b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageScene.cpp index ca43ebe8f820..9db8c37d923f 100644 --- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageScene.cpp +++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageScene.cpp @@ -41,7 +41,7 @@ KX_NetworkMessageScene::~KX_NetworkMessageScene() { } -void KX_NetworkMessageScene::SendMessage(STR_String to, SCA_IObject *from, STR_String subject, STR_String body) +void KX_NetworkMessageScene::SendMessage(std::string to, SCA_IObject *from, std::string subject, std::string body) { KX_NetworkMessageManager::Message message; message.to = to; @@ -53,7 +53,7 @@ void KX_NetworkMessageScene::SendMessage(STR_String to, SCA_IObject *from, STR_S m_messageManager->AddMessage(message); } -const std::vector KX_NetworkMessageScene::FindMessages(STR_String to, STR_String subject) +const std::vector KX_NetworkMessageScene::FindMessages(std::string to, std::string subject) { return m_messageManager->GetMessages(to, subject); } diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageScene.h b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageScene.h index 5cfeed7f5468..cb5e62865dfa 100644 --- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageScene.h +++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageScene.h @@ -39,7 +39,7 @@ conflicts with KX_NetworkMessageScene::SendMessage */ #endif #include "KX_NetworkMessageManager.h" -#include "STR_String.h" +#include #include #include @@ -61,13 +61,13 @@ class KX_NetworkMessageScene * \param subject The message subject, used as filter for receiver object(s). * \param message The body of the message. */ - void SendMessage(STR_String to, SCA_IObject *from, STR_String subject, STR_String body); + void SendMessage(std::string to, SCA_IObject *from, std::string subject, std::string body); /** Get all messages for a given receiver object name and message subject. * \param to The object(s) name. * \param subject The message subject/filter. */ - const std::vector FindMessages(STR_String to, STR_String subject); + const std::vector FindMessages(std::string to, std::string subject); }; #endif // __KX_NETWORKMESSAGESCENE_H__ diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp index 93ff8923beef..883bc4fc2fb5 100644 --- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp +++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp @@ -48,7 +48,7 @@ KX_NetworkMessageSensor::KX_NetworkMessageSensor( SCA_EventManager *eventmgr, // our eventmanager class KX_NetworkMessageScene *NetworkScene, // our scene SCA_IObject *gameobj, // the sensor controlling object - const STR_String &subject) + const std::string &subject) :SCA_ISensor(gameobj, eventmgr), m_NetworkScene(NetworkScene), m_subject(subject), @@ -100,8 +100,8 @@ bool KX_NetworkMessageSensor::Evaluate() m_SubjectList = NULL; } - STR_String toname = GetParent()->GetName(); - STR_String& subject = this->m_subject; + std::string toname = GetParent()->GetName(); + std::string& subject = this->m_subject; const std::vector messages = m_NetworkScene->FindMessages(toname, subject); @@ -120,9 +120,9 @@ bool KX_NetworkMessageSensor::Evaluate() std::vector::const_iterator mesit; for (mesit = messages.begin(); mesit != messages.end(); mesit++) { // save the body - const STR_String& body = (*mesit).body; + const std::string& body = (*mesit).body; // save the subject - const STR_String& messub = (*mesit).subject; + const std::string& messub = (*mesit).subject; #ifdef NAN_NET_DEBUG if (body) { cout << "body [" << body << "]\n"; @@ -190,7 +190,7 @@ PyAttributeDef KX_NetworkMessageSensor::Attributes[] = { KX_PYATTRIBUTE_INT_RO("frameMessageCount", KX_NetworkMessageSensor, m_frame_message_count), KX_PYATTRIBUTE_RO_FUNCTION("bodies", KX_NetworkMessageSensor, pyattr_get_bodies), KX_PYATTRIBUTE_RO_FUNCTION("subjects", KX_NetworkMessageSensor, pyattr_get_subjects), - {NULL} //Sentinel + KX_PYATTRIBUTE_NULL //Sentinel }; PyObject *KX_NetworkMessageSensor::pyattr_get_bodies(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.h b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.h index b2ca14d480e7..de3bb0ab133d 100644 --- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.h +++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.h @@ -43,7 +43,7 @@ class KX_NetworkMessageSensor : public SCA_ISensor KX_NetworkMessageScene *m_NetworkScene; // The subject we filter on. - STR_String m_subject; + std::string m_subject; // The number of messages caught since the last frame. int m_frame_message_count; @@ -58,7 +58,7 @@ class KX_NetworkMessageSensor : public SCA_ISensor SCA_EventManager *eventmgr, // our eventmanager KX_NetworkMessageScene *NetworkScene, // our scene SCA_IObject *gameobj, // the sensor controlling object - const STR_String &subject); + const std::string &subject); virtual ~KX_NetworkMessageSensor(); virtual CValue *GetReplica(); diff --git a/source/gameengine/Ketsji/KX_2DFilter.cpp b/source/gameengine/Ketsji/KX_2DFilter.cpp index 45af46bbe25c..a4a42901f9a8 100644 --- a/source/gameengine/Ketsji/KX_2DFilter.cpp +++ b/source/gameengine/Ketsji/KX_2DFilter.cpp @@ -71,7 +71,7 @@ PyMethodDef KX_2DFilter::Methods[] = { }; PyAttributeDef KX_2DFilter::Attributes[] = { - {NULL} // Sentinel + KX_PYATTRIBUTE_NULL // Sentinel }; diff --git a/source/gameengine/Ketsji/KX_2DFilterManager.cpp b/source/gameengine/Ketsji/KX_2DFilterManager.cpp index 505b09937d49..c4112b3eb444 100644 --- a/source/gameengine/Ketsji/KX_2DFilterManager.cpp +++ b/source/gameengine/Ketsji/KX_2DFilterManager.cpp @@ -52,7 +52,7 @@ PyMethodDef KX_2DFilterManager::Methods[] = { }; PyAttributeDef KX_2DFilterManager::Attributes[] = { - {NULL} //Sentinel + KX_PYATTRIBUTE_NULL //Sentinel }; PyTypeObject KX_2DFilterManager::Type = { @@ -121,7 +121,7 @@ KX_PYMETHODDEF_DOC(KX_2DFilterManager, addFilter, " addFilter(index, type, fragm RAS_2DFilterData data; data.filterPassIndex = index; data.filterMode = type; - data.shaderText = STR_String(frag); + data.shaderText = std::string(frag); AddFilter(data); diff --git a/source/gameengine/Ketsji/KX_ArmatureSensor.cpp b/source/gameengine/Ketsji/KX_ArmatureSensor.cpp index c111a4de0eb7..c722abd19507 100644 --- a/source/gameengine/Ketsji/KX_ArmatureSensor.cpp +++ b/source/gameengine/Ketsji/KX_ArmatureSensor.cpp @@ -45,8 +45,8 @@ KX_ArmatureSensor::KX_ArmatureSensor(class SCA_EventManager* eventmgr, SCA_IObject* gameobj, - const char *posechannel, - const char *constraintname, + const std::string& posechannel, + const std::string& constraintname, int type, float value) : SCA_ISensor(gameobj,eventmgr), @@ -78,10 +78,10 @@ void KX_ArmatureSensor::FindConstraint() bConstraint* pcon; // and locate the constraint for (pchan = (bPoseChannel*)pose->chanbase.first; pchan; pchan=(bPoseChannel*)pchan->next) { - if (!strcmp(pchan->name, m_posechannel)) { + if (pchan->name == m_posechannel) { // now locate the constraint for (pcon = (bConstraint *)pchan->constraints.first; pcon; pcon = (bConstraint *)pcon->next) { - if (!strcmp(pcon->name, m_constraintname)) { + if (pcon->name == m_constraintname) { if (pcon->flag & CONSTRAINT_DISABLE) /* this constraint is not valid, can't use it */ break; @@ -190,7 +190,7 @@ PyAttributeDef KX_ArmatureSensor::Attributes[] = { KX_PYATTRIBUTE_RO_FUNCTION("constraint", KX_ArmatureSensor, pyattr_get_constraint), KX_PYATTRIBUTE_FLOAT_RW("value",-FLT_MAX,FLT_MAX,KX_ArmatureSensor,m_value), KX_PYATTRIBUTE_INT_RW("type",0,SENS_ARM_MAXTYPE,false,KX_ArmatureSensor,m_type), - { NULL } //Sentinel + KX_PYATTRIBUTE_NULL //Sentinel }; PyObject *KX_ArmatureSensor::pyattr_get_constraint(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef) diff --git a/source/gameengine/Ketsji/KX_ArmatureSensor.h b/source/gameengine/Ketsji/KX_ArmatureSensor.h index b3ea905d1986..bc02cc0669c6 100644 --- a/source/gameengine/Ketsji/KX_ArmatureSensor.h +++ b/source/gameengine/Ketsji/KX_ArmatureSensor.h @@ -48,8 +48,8 @@ class KX_ArmatureSensor : public SCA_ISensor public: KX_ArmatureSensor(class SCA_EventManager* eventmgr, SCA_IObject* gameobj, - const char *posechannel, - const char *constraintname, + const std::string& posechannel, + const std::string& constraintname, int type, float value); @@ -78,8 +78,8 @@ class KX_ArmatureSensor : public SCA_ISensor private: struct bConstraint* m_constraint; - STR_String m_posechannel; - STR_String m_constraintname; + std::string m_posechannel; + std::string m_constraintname; int m_type; float m_value; bool m_result; diff --git a/source/gameengine/Ketsji/KX_BlenderMaterial.cpp b/source/gameengine/Ketsji/KX_BlenderMaterial.cpp index 0ef70386c3d1..902038f9532a 100644 --- a/source/gameengine/Ketsji/KX_BlenderMaterial.cpp +++ b/source/gameengine/Ketsji/KX_BlenderMaterial.cpp @@ -153,7 +153,7 @@ void KX_BlenderMaterial::GetRGBAColor(unsigned char *rgba) const RAS_IPolyMaterial::GetRGBAColor(rgba); } -const STR_String KX_BlenderMaterial::GetTextureName() const +const std::string KX_BlenderMaterial::GetTextureName() const { return (m_textures[0] ? m_textures[0]->GetName() : ""); } @@ -524,7 +524,7 @@ void KX_BlenderMaterial::SetBlenderGLSLShader() } } -STR_String KX_BlenderMaterial::GetName() +std::string KX_BlenderMaterial::GetName() { return m_name; } @@ -662,7 +662,7 @@ PyAttributeDef KX_BlenderMaterial::Attributes[] = { KX_PYATTRIBUTE_RW_FUNCTION("ambient", KX_BlenderMaterial, pyattr_get_ambient, pyattr_set_ambient), KX_PYATTRIBUTE_RW_FUNCTION("specularAlpha", KX_BlenderMaterial, pyattr_get_specular_alpha, pyattr_set_specular_alpha), - {NULL} //Sentinel + KX_PYATTRIBUTE_NULL //Sentinel }; PyTypeObject KX_BlenderMaterial::Type = { @@ -712,10 +712,10 @@ static PyObject *kx_blender_material_get_textures_item_cb(void *self_v, int inde return item; } -static const char *kx_blender_material_get_textures_item_name_cb(void *self_v, int index) +static const std::string kx_blender_material_get_textures_item_name_cb(void *self_v, int index) { BL_Texture *tex = (BL_Texture *)((KX_BlenderMaterial *)self_v)->GetTexture(index); - return (tex ? tex->GetName().ReadPtr() : ""); + return (tex ? tex->GetName() : ""); } PyObject *KX_BlenderMaterial::pyattr_get_textures(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) @@ -748,7 +748,7 @@ int KX_BlenderMaterial::pyattr_set_alpha(void *self_v, const KX_PYATTRIBUTE_DEF float val = PyFloat_AsDouble(value); if (val == -1 && PyErr_Occurred()) { - PyErr_Format(PyExc_AttributeError, "material.%s = float: KX_BlenderMaterial, expected a float", attrdef->m_name); + PyErr_Format(PyExc_AttributeError, "material.%s = float: KX_BlenderMaterial, expected a float", attrdef->m_name.c_str()); return PY_SET_ATTR_FAIL; } @@ -770,7 +770,7 @@ int KX_BlenderMaterial::pyattr_set_specular_alpha(void *self_v, const KX_PYATTRI float val = PyFloat_AsDouble(value); if (val == -1 && PyErr_Occurred()) { - PyErr_Format(PyExc_AttributeError, "material.%s = float: KX_BlenderMaterial, expected a float", attrdef->m_name); + PyErr_Format(PyExc_AttributeError, "material.%s = float: KX_BlenderMaterial, expected a float", attrdef->m_name.c_str()); return PY_SET_ATTR_FAIL; } @@ -792,7 +792,7 @@ int KX_BlenderMaterial::pyattr_set_hardness(void *self_v, const KX_PYATTRIBUTE_D int val = PyLong_AsLong(value); if (val == -1 && PyErr_Occurred()) { - PyErr_Format(PyExc_AttributeError, "material.%s = int: KX_BlenderMaterial, expected a int", attrdef->m_name); + PyErr_Format(PyExc_AttributeError, "material.%s = int: KX_BlenderMaterial, expected a int", attrdef->m_name.c_str()); return PY_SET_ATTR_FAIL; } @@ -814,7 +814,7 @@ int KX_BlenderMaterial::pyattr_set_specular_intensity(void *self_v, const KX_PYA float val = PyFloat_AsDouble(value); if (val == -1 && PyErr_Occurred()) { - PyErr_Format(PyExc_AttributeError, "material.%s = float: KX_BlenderMaterial, expected a float", attrdef->m_name); + PyErr_Format(PyExc_AttributeError, "material.%s = float: KX_BlenderMaterial, expected a float", attrdef->m_name.c_str()); return PY_SET_ATTR_FAIL; } @@ -861,7 +861,7 @@ int KX_BlenderMaterial::pyattr_set_diffuse_intensity(void *self_v, const KX_PYAT float val = PyFloat_AsDouble(value); if (val == -1 && PyErr_Occurred()) { - PyErr_Format(PyExc_AttributeError, "material.%s = float: KX_BlenderMaterial, expected a float", attrdef->m_name); + PyErr_Format(PyExc_AttributeError, "material.%s = float: KX_BlenderMaterial, expected a float", attrdef->m_name.c_str()); return PY_SET_ATTR_FAIL; } @@ -908,7 +908,7 @@ int KX_BlenderMaterial::pyattr_set_emit(void *self_v, const KX_PYATTRIBUTE_DEF * float val = PyFloat_AsDouble(value); if (val == -1 && PyErr_Occurred()) { - PyErr_Format(PyExc_AttributeError, "material.%s = float: KX_BlenderMaterial, expected a float", attrdef->m_name); + PyErr_Format(PyExc_AttributeError, "material.%s = float: KX_BlenderMaterial, expected a float", attrdef->m_name.c_str()); return PY_SET_ATTR_FAIL; } @@ -930,7 +930,7 @@ int KX_BlenderMaterial::pyattr_set_ambient(void *self_v, const KX_PYATTRIBUTE_DE float val = PyFloat_AsDouble(value); if (val == -1 && PyErr_Occurred()) { - PyErr_Format(PyExc_AttributeError, "material.%s = float: KX_BlenderMaterial, expected a float", attrdef->m_name); + PyErr_Format(PyExc_AttributeError, "material.%s = float: KX_BlenderMaterial, expected a float", attrdef->m_name.c_str()); return PY_SET_ATTR_FAIL; } diff --git a/source/gameengine/Ketsji/KX_BlenderMaterial.h b/source/gameengine/Ketsji/KX_BlenderMaterial.h index e01835b757d5..a9aac5d34823 100644 --- a/source/gameengine/Ketsji/KX_BlenderMaterial.h +++ b/source/gameengine/Ketsji/KX_BlenderMaterial.h @@ -54,7 +54,7 @@ class KX_BlenderMaterial : public CValue, public RAS_IPolyMaterial void ActivateBlenderShaders(RAS_IRasterizer *rasty); virtual bool UseInstancing() const; - virtual const STR_String GetTextureName() const; + virtual const std::string GetTextureName() const; virtual Material *GetBlenderMaterial() const; virtual Image *GetBlenderImage() const; virtual MTexPoly *GetMTexPoly() const; @@ -77,7 +77,7 @@ class KX_BlenderMaterial : public CValue, public RAS_IPolyMaterial virtual void Replace_IScene(SCA_IScene *val); // Stuff for cvalue related things. - virtual STR_String GetName(); + virtual std::string GetName(); #ifdef WITH_PYTHON diff --git a/source/gameengine/Ketsji/KX_BoundingBox.cpp b/source/gameengine/Ketsji/KX_BoundingBox.cpp index ed88c80c4d4f..049afe6d3df8 100644 --- a/source/gameengine/Ketsji/KX_BoundingBox.cpp +++ b/source/gameengine/Ketsji/KX_BoundingBox.cpp @@ -237,7 +237,7 @@ PyAttributeDef KX_BoundingBox::Attributes[] = { KX_PYATTRIBUTE_RO_FUNCTION("center", KX_BoundingBox, pyattr_get_center), KX_PYATTRIBUTE_RO_FUNCTION("radius", KX_BoundingBox, pyattr_get_radius), KX_PYATTRIBUTE_RW_FUNCTION("autoUpdate", KX_BoundingBox, pyattr_get_auto_update, pyattr_set_auto_update), - {NULL} // Sentinel + KX_PYATTRIBUTE_NULL // Sentinel }; PyObject *KX_BoundingBox::py_repr() @@ -245,7 +245,7 @@ PyObject *KX_BoundingBox::py_repr() if (!IsValidOwner()) { return PyUnicode_FromString("KX_BoundingBox of invalid object"); } - return PyUnicode_FromFormat("KX_BoundingBox of object %s, min: %R, max: %R", m_owner->GetName().ReadPtr(), + return PyUnicode_FromFormat("KX_BoundingBox of object %s, min: %R, max: %R", m_owner->GetName().c_str(), PyObjectFrom(GetMin()), PyObjectFrom(GetMax())); } diff --git a/source/gameengine/Ketsji/KX_Camera.cpp b/source/gameengine/Ketsji/KX_Camera.cpp index 5564c874d51a..24b06fa1a7f5 100644 --- a/source/gameengine/Ketsji/KX_Camera.cpp +++ b/source/gameengine/Ketsji/KX_Camera.cpp @@ -572,7 +572,7 @@ PyAttributeDef KX_Camera::Attributes[] = { KX_PYATTRIBUTE_RO_FUNCTION("OUTSIDE", KX_Camera, pyattr_get_OUTSIDE), KX_PYATTRIBUTE_RO_FUNCTION("INTERSECT", KX_Camera, pyattr_get_INTERSECT), - { NULL } //Sentinel + KX_PYATTRIBUTE_NULL //Sentinel }; PyTypeObject KX_Camera::Type = { @@ -997,7 +997,7 @@ bool ConvertPythonToCamera(KX_Scene *scene, PyObject *value, KX_Camera **object, } if (PyUnicode_Check(value)) { - STR_String value_str = _PyUnicode_AsString(value); + std::string value_str = _PyUnicode_AsString(value); *object = (KX_Camera*)scene->GetCameraList()->FindValue(value_str); if (*object) { diff --git a/source/gameengine/Ketsji/KX_CameraActuator.cpp b/source/gameengine/Ketsji/KX_CameraActuator.cpp index 726a0e88d060..076111213418 100644 --- a/source/gameengine/Ketsji/KX_CameraActuator.cpp +++ b/source/gameengine/Ketsji/KX_CameraActuator.cpp @@ -348,12 +348,6 @@ bool KX_CameraActuator::Update(double curtime, bool frame) return true; } -CValue *KX_CameraActuator::findObject(const char *obName) -{ - /* hook to object system */ - return NULL; -} - #ifdef WITH_PYTHON /* ------------------------------------------------------------------------- */ @@ -394,7 +388,7 @@ PyAttributeDef KX_CameraActuator::Attributes[] = { KX_PYATTRIBUTE_SHORT_RW("axis", 0, 5, true, KX_CameraActuator, m_axis), KX_PYATTRIBUTE_RW_FUNCTION("object", KX_CameraActuator, pyattr_get_object, pyattr_set_object), KX_PYATTRIBUTE_FLOAT_RW("damping",0.f,10.f,KX_CameraActuator,m_damping), - {NULL} + KX_PYATTRIBUTE_NULL }; PyObject *KX_CameraActuator::pyattr_get_object(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) diff --git a/source/gameengine/Ketsji/KX_CameraActuator.h b/source/gameengine/Ketsji/KX_CameraActuator.h index 7798801bcd46..cce90f60aab4 100644 --- a/source/gameengine/Ketsji/KX_CameraActuator.h +++ b/source/gameengine/Ketsji/KX_CameraActuator.h @@ -76,15 +76,9 @@ private : /** damping (float), */ float m_damping; - /* get the KX_IGameObject with this name */ - CValue *findObject(const char *obName); - - /* parse x or y to a toggle pick */ - bool string2axischoice(const char *axisString); - - public: - static STR_String X_AXIS_STRING; - static STR_String Y_AXIS_STRING; +public: + static std::string X_AXIS_STRING; + static std::string Y_AXIS_STRING; /** * Set the bool toggle to true to use x lock, false for y lock diff --git a/source/gameengine/Ketsji/KX_CharacterWrapper.cpp b/source/gameengine/Ketsji/KX_CharacterWrapper.cpp index 90f8a9a6e266..462d543071c1 100644 --- a/source/gameengine/Ketsji/KX_CharacterWrapper.cpp +++ b/source/gameengine/Ketsji/KX_CharacterWrapper.cpp @@ -36,7 +36,7 @@ KX_CharacterWrapper::~KX_CharacterWrapper() { } -STR_String KX_CharacterWrapper::GetName() +std::string KX_CharacterWrapper::GetName() { return "KX_CharacterWrapper"; } @@ -71,7 +71,7 @@ PyAttributeDef KX_CharacterWrapper::Attributes[] = { KX_PYATTRIBUTE_RW_FUNCTION("maxJumps", KX_CharacterWrapper, pyattr_get_max_jumps, pyattr_set_max_jumps), KX_PYATTRIBUTE_RO_FUNCTION("jumpCount", KX_CharacterWrapper, pyattr_get_jump_count), KX_PYATTRIBUTE_RW_FUNCTION("walkDirection", KX_CharacterWrapper, pyattr_get_walk_dir, pyattr_set_walk_dir), - { NULL } //Sentinel + KX_PYATTRIBUTE_NULL //Sentinel }; PyObject *KX_CharacterWrapper::pyattr_get_onground(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) diff --git a/source/gameengine/Ketsji/KX_CharacterWrapper.h b/source/gameengine/Ketsji/KX_CharacterWrapper.h index f131c5fa8577..96fd254427cf 100644 --- a/source/gameengine/Ketsji/KX_CharacterWrapper.h +++ b/source/gameengine/Ketsji/KX_CharacterWrapper.h @@ -20,7 +20,7 @@ class KX_CharacterWrapper : public CValue KX_CharacterWrapper(PHY_ICharacter* character); virtual ~KX_CharacterWrapper(); - virtual STR_String GetName(); + virtual std::string GetName(); #ifdef WITH_PYTHON KX_PYMETHOD_DOC_NOARGS(KX_CharacterWrapper, jump); diff --git a/source/gameengine/Ketsji/KX_CollisionContactPoints.cpp b/source/gameengine/Ketsji/KX_CollisionContactPoints.cpp index 016e84b9de31..8ff1e1f3bd82 100644 --- a/source/gameengine/Ketsji/KX_CollisionContactPoints.cpp +++ b/source/gameengine/Ketsji/KX_CollisionContactPoints.cpp @@ -39,7 +39,7 @@ KX_CollisionContactPoint::~KX_CollisionContactPoint() { } -STR_String KX_CollisionContactPoint::GetName() +std::string KX_CollisionContactPoint::GetName() { return "CollisionContactPoint"; } @@ -80,7 +80,7 @@ PyAttributeDef KX_CollisionContactPoint::Attributes[] = { KX_PYATTRIBUTE_RO_FUNCTION("combinedFriction", KX_CollisionContactPoint, pyattr_get_combined_friction), KX_PYATTRIBUTE_RO_FUNCTION("combinedRestitution", KX_CollisionContactPoint, pyattr_get_combined_restitution), KX_PYATTRIBUTE_RO_FUNCTION("appliedImpulse", KX_CollisionContactPoint, pyattr_get_applied_impulse), - {NULL} //Sentinel + KX_PYATTRIBUTE_NULL //Sentinel }; PyObject *KX_CollisionContactPoint::pyattr_get_local_point_a(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) diff --git a/source/gameengine/Ketsji/KX_CollisionContactPoints.h b/source/gameengine/Ketsji/KX_CollisionContactPoints.h index b83b1587dd2f..4c6338b4246b 100644 --- a/source/gameengine/Ketsji/KX_CollisionContactPoints.h +++ b/source/gameengine/Ketsji/KX_CollisionContactPoints.h @@ -46,7 +46,7 @@ class KX_CollisionContactPoint : public CValue virtual ~KX_CollisionContactPoint(); // stuff for cvalue related things - STR_String GetName(); + std::string GetName(); #ifdef WITH_PYTHON diff --git a/source/gameengine/Ketsji/KX_CollisionSensor.cpp b/source/gameengine/Ketsji/KX_CollisionSensor.cpp index 70e32f96a09b..e541dd5feb98 100644 --- a/source/gameengine/Ketsji/KX_CollisionSensor.cpp +++ b/source/gameengine/Ketsji/KX_CollisionSensor.cpp @@ -101,7 +101,7 @@ bool KX_CollisionSensor::Evaluate() return result; } -KX_CollisionSensor::KX_CollisionSensor(SCA_EventManager *eventmgr, KX_GameObject *gameobj, bool bFindMaterial, bool bCollisionPulse, const STR_String& touchedpropname) +KX_CollisionSensor::KX_CollisionSensor(SCA_EventManager *eventmgr, KX_GameObject *gameobj, bool bFindMaterial, bool bCollisionPulse, const std::string& touchedpropname) :SCA_ISensor(gameobj, eventmgr), m_touchedpropname(touchedpropname), m_bFindMaterial(bFindMaterial), @@ -208,13 +208,13 @@ bool KX_CollisionSensor::BroadPhaseSensorFilterCollision(void *obj1, void *obj2) return false; } - bool found = m_touchedpropname.IsEmpty(); + bool found = m_touchedpropname.empty(); if (!found) { if (m_bFindMaterial) { for (unsigned int i = 0; i < otherobj->GetMeshCount(); ++i) { RAS_MeshObject *meshObj = otherobj->GetMesh(i); for (unsigned int j = 0; j < meshObj->NumMaterials(); ++j) { - found = strcmp(m_touchedpropname.ReadPtr(), meshObj->GetMaterialName(j).ReadPtr() + 2) == 0; + found = (m_touchedpropname == std::string(meshObj->GetMaterialName(j), 2)); if (found) { break; } @@ -248,14 +248,14 @@ bool KX_CollisionSensor::NewHandleCollision(void *object1, void *object2, const gameobj && (gameobj != parent) && client_info->isActor()) { - bool found = m_touchedpropname.IsEmpty(); + bool found = m_touchedpropname.empty(); bool hitMaterial = false; if (!found) { if (m_bFindMaterial) { for (unsigned int i = 0; i < gameobj->GetMeshCount(); ++i) { RAS_MeshObject *meshObj = gameobj->GetMesh(i); for (unsigned int j = 0; j < meshObj->NumMaterials(); ++j) { - found = strcmp(m_touchedpropname.ReadPtr(), meshObj->GetMaterialName(j).ReadPtr() + 2) == 0; + found = (m_touchedpropname == std::string(meshObj->GetMaterialName(j), 2)); if (found) { hitMaterial = true; break; @@ -323,7 +323,7 @@ PyAttributeDef KX_CollisionSensor::Attributes[] = { KX_PYATTRIBUTE_STRING_RO("hitMaterial", KX_CollisionSensor, m_hitMaterial), KX_PYATTRIBUTE_RO_FUNCTION("hitObject", KX_CollisionSensor, pyattr_get_object_hit), KX_PYATTRIBUTE_RO_FUNCTION("hitObjectList", KX_CollisionSensor, pyattr_get_object_hit_list), - {NULL} //Sentinel + KX_PYATTRIBUTE_NULL //Sentinel }; /* Python API */ diff --git a/source/gameengine/Ketsji/KX_CollisionSensor.h b/source/gameengine/Ketsji/KX_CollisionSensor.h index e38321556413..328644acb86d 100644 --- a/source/gameengine/Ketsji/KX_CollisionSensor.h +++ b/source/gameengine/Ketsji/KX_CollisionSensor.h @@ -56,7 +56,7 @@ class KX_CollisionSensor : public SCA_ISensor /** * The sensor should only look for objects with this property. */ - STR_String m_touchedpropname; + std::string m_touchedpropname; bool m_bFindMaterial; bool m_bCollisionPulse; /* changes in the colliding objects trigger pulses */ @@ -73,14 +73,14 @@ class KX_CollisionSensor : public SCA_ISensor SCA_IObject *m_hitObject; class CListValue * m_colliders; - STR_String m_hitMaterial; + std::string m_hitMaterial; public: KX_CollisionSensor(class SCA_EventManager *eventmgr, class KX_GameObject *gameobj, bool bFindMaterial, bool bCollisionPulse, - const STR_String& touchedpropname); + const std::string& touchedpropname); virtual ~KX_CollisionSensor(); virtual CValue *GetReplica(); diff --git a/source/gameengine/Ketsji/KX_ConstraintActuator.cpp b/source/gameengine/Ketsji/KX_ConstraintActuator.cpp index d1314ddb276a..57d82e7fd8e5 100644 --- a/source/gameengine/Ketsji/KX_ConstraintActuator.cpp +++ b/source/gameengine/Ketsji/KX_ConstraintActuator.cpp @@ -124,7 +124,7 @@ bool KX_ConstraintActuator::RayHit(KX_ClientObjectInfo *client, KX_RayCast *resu bool bFound = false; - if (m_property.IsEmpty()) + if (m_property.empty()) { bFound = true; } @@ -134,7 +134,7 @@ bool KX_ConstraintActuator::RayHit(KX_ClientObjectInfo *client, KX_RayCast *resu for (unsigned int i = 0; i < m_hitObject->GetMeshCount(); ++i) { RAS_MeshObject *meshObj = m_hitObject->GetMesh(i); for (unsigned int j = 0; j < meshObj->NumMaterials(); ++j) { - bFound = strcmp(m_property.ReadPtr(), meshObj->GetMaterialName(j).ReadPtr() + 2) == 0; + bFound = (m_property == std::string(meshObj->GetMaterialName(j), 2)); if (bFound) break; } @@ -608,7 +608,7 @@ PyAttributeDef KX_ConstraintActuator::Attributes[] = { KX_PYATTRIBUTE_FLOAT_RW("max",-FLT_MAX,FLT_MAX,KX_ConstraintActuator,m_maximumBound), KX_PYATTRIBUTE_FLOAT_RW("rayLength",0,2000.f,KX_ConstraintActuator,m_maximumBound), KX_PYATTRIBUTE_INT_RW("limit",KX_ConstraintActuator::KX_ACT_CONSTRAINT_NODEF+1,KX_ConstraintActuator::KX_ACT_CONSTRAINT_MAX-1,false,KX_ConstraintActuator,m_locrot), - { NULL } //Sentinel + KX_PYATTRIBUTE_NULL //Sentinel }; int KX_ConstraintActuator::pyattr_check_direction(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef) diff --git a/source/gameengine/Ketsji/KX_ConstraintActuator.h b/source/gameengine/Ketsji/KX_ConstraintActuator.h index af617655d5e8..6fa7472fe314 100644 --- a/source/gameengine/Ketsji/KX_ConstraintActuator.h +++ b/source/gameengine/Ketsji/KX_ConstraintActuator.h @@ -68,7 +68,7 @@ class KX_ConstraintActuator : public SCA_IActuator // option int m_option; // property to check - STR_String m_property; + std::string m_property; // hit object KX_GameObject* m_hitObject; diff --git a/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp b/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp index c8375e7d28e4..d7e7afeddca5 100644 --- a/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp +++ b/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp @@ -47,7 +47,7 @@ KX_ConstraintWrapper::~KX_ConstraintWrapper() { } -STR_String KX_ConstraintWrapper::GetName() +std::string KX_ConstraintWrapper::GetName() { return "KX_ConstraintWrapper"; } @@ -119,7 +119,7 @@ PyMethodDef KX_ConstraintWrapper::Methods[] = { PyAttributeDef KX_ConstraintWrapper::Attributes[] = { KX_PYATTRIBUTE_RO_FUNCTION("constraint_id", KX_ConstraintWrapper, pyattr_get_constraintId), KX_PYATTRIBUTE_RO_FUNCTION("constraint_type", KX_ConstraintWrapper, pyattr_get_constraintType), - { NULL } //Sentinel + KX_PYATTRIBUTE_NULL //Sentinel }; PyObject *KX_ConstraintWrapper::pyattr_get_constraintId(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) diff --git a/source/gameengine/Ketsji/KX_ConstraintWrapper.h b/source/gameengine/Ketsji/KX_ConstraintWrapper.h index 7a522437985b..10f6033ef672 100644 --- a/source/gameengine/Ketsji/KX_ConstraintWrapper.h +++ b/source/gameengine/Ketsji/KX_ConstraintWrapper.h @@ -42,7 +42,7 @@ class KX_ConstraintWrapper : public CValue KX_ConstraintWrapper(PHY_ConstraintType ctype,int constraintId,class PHY_IPhysicsEnvironment* physenv); virtual ~KX_ConstraintWrapper (); - virtual STR_String GetName(); + virtual std::string GetName(); int getConstraintId() { return m_constraintId; } diff --git a/source/gameengine/Ketsji/KX_CubeMap.cpp b/source/gameengine/Ketsji/KX_CubeMap.cpp index f697e627fd7e..e513cc2d8437 100644 --- a/source/gameengine/Ketsji/KX_CubeMap.cpp +++ b/source/gameengine/Ketsji/KX_CubeMap.cpp @@ -48,7 +48,7 @@ KX_CubeMap::~KX_CubeMap() { } -STR_String KX_CubeMap::GetName() +std::string KX_CubeMap::GetName() { return "KX_CubeMap"; } @@ -157,7 +157,7 @@ PyAttributeDef KX_CubeMap::Attributes[] = { KX_PYATTRIBUTE_INT_RW("ignoreLayers", 0, (1 << 20) - 1, true, KX_CubeMap, m_ignoreLayers), KX_PYATTRIBUTE_RW_FUNCTION("clipStart", KX_CubeMap, pyattr_get_clip_start, pyattr_set_clip_start), KX_PYATTRIBUTE_RW_FUNCTION("clipEnd", KX_CubeMap, pyattr_get_clip_end, pyattr_set_clip_end), - {NULL} // Sentinel + KX_PYATTRIBUTE_NULL // Sentinel }; KX_PYMETHODDEF_DOC_NOARGS(KX_CubeMap, update, "update(): Set the cube map to be updated next frame.\n") diff --git a/source/gameengine/Ketsji/KX_CubeMap.h b/source/gameengine/Ketsji/KX_CubeMap.h index d24fa2c5f55c..f614119278fd 100644 --- a/source/gameengine/Ketsji/KX_CubeMap.h +++ b/source/gameengine/Ketsji/KX_CubeMap.h @@ -71,7 +71,7 @@ class KX_CubeMap : public CValue, public RAS_CubeMap KX_CubeMap(EnvMap *env, KX_GameObject *viewpoint); virtual ~KX_CubeMap(); - virtual STR_String GetName(); + virtual std::string GetName(); KX_GameObject *GetViewpointObject() const; void SetViewpointObject(KX_GameObject *gameobj); diff --git a/source/gameengine/Ketsji/KX_FontObject.cpp b/source/gameengine/Ketsji/KX_FontObject.cpp index 381a27e36e99..efb3f18f270d 100644 --- a/source/gameengine/Ketsji/KX_FontObject.cpp +++ b/source/gameengine/Ketsji/KX_FontObject.cpp @@ -62,21 +62,21 @@ extern "C" { /* proptotype */ int GetFontId(VFont *font); -static std::vector split_string(STR_String str) +static std::vector split_string(std::string str) { - std::vector text = std::vector(); + std::vector text = std::vector(); // Split the string upon new lines int begin = 0, end = 0; - while (end < str.Length()) { - if (str.GetAt(end) == '\n') { - text.push_back(str.Mid(begin, end - begin)); + while (end < str.size()) { + if (str[end] == '\n') { + text.push_back(str.substr(begin, end - begin)); begin = end + 1; } end++; } // Now grab the last line - text.push_back(str.Mid(begin, end - begin)); + text.push_back(str.substr(begin, end - begin)); return text; } @@ -207,11 +207,11 @@ const MT_Vector2 KX_FontObject::GetTextDimensions() { MT_Vector2 dimensions(0.0f, 0.0f); - for (std::vector::iterator it = m_text.begin(); it != m_text.end(); ++it) { + for (std::vector::iterator it = m_text.begin(); it != m_text.end(); ++it) { float w = 0.0f, h = 0.0f; - const STR_String& text = *it; + const std::string& text = *it; - BLF_width_and_height(m_fontid, text.ReadPtr(), text.Length(), &w, &h); + BLF_width_and_height(m_fontid, text.c_str(), text.size(), &w, &h); dimensions.x() = std::max(dimensions.x(), w); dimensions.y() += h + m_line_spacing; } @@ -261,7 +261,7 @@ int GetFontId(VFont *vfont) // convert from absolute to relative char expanded[256]; // font names can be bigger than FILE_MAX (240) BLI_strncpy(expanded, filepath, 256); - BLI_path_abs(expanded, KX_GetMainPath().ReadPtr()); + BLI_path_abs(expanded, KX_GetMainPath().c_str()); fontid = BLF_load(expanded); @@ -317,19 +317,19 @@ PyAttributeDef KX_FontObject::Attributes[] = { KX_PYATTRIBUTE_FLOAT_RW("size", 0.0001f, 40.0f, KX_FontObject, m_fsize), KX_PYATTRIBUTE_FLOAT_RW("resolution", 0.1f, 50.0f, KX_FontObject, m_resolution), /* KX_PYATTRIBUTE_INT_RW("dpi", 0, 10000, false, KX_FontObject, m_dpi), */// no real need for expose this I think - {NULL} //Sentinel + KX_PYATTRIBUTE_NULL //Sentinel }; PyObject *KX_FontObject::pyattr_get_text(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { KX_FontObject *self = static_cast(self_v); - STR_String str = STR_String(); + std::string str = std::string(); for (unsigned int i = 0; i < self->m_text.size(); ++i) { if (i != 0) str += '\n'; str += self->m_text[i]; } - return PyUnicode_From_STR_String(str); + return PyUnicode_FromStdString(str); } int KX_FontObject::pyattr_set_text(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) @@ -342,12 +342,12 @@ int KX_FontObject::pyattr_set_text(void *self_v, const KX_PYATTRIBUTE_DEF *attrd /* Allow for some logic brick control */ CValue *tprop = self->GetProperty("Text"); if (tprop) { - CValue *newstringprop = new CStringValue(STR_String(chars), "Text"); + CValue *newstringprop = new CStringValue(std::string(chars), "Text"); self->SetProperty("Text", newstringprop); newstringprop->Release(); } else { - self->m_text = split_string(STR_String(chars)); + self->m_text = split_string(std::string(chars)); } return PY_SET_ATTR_SUCCESS; diff --git a/source/gameengine/Ketsji/KX_FontObject.h b/source/gameengine/Ketsji/KX_FontObject.h index 6611b9f0e873..afba386463ed 100644 --- a/source/gameengine/Ketsji/KX_FontObject.h +++ b/source/gameengine/Ketsji/KX_FontObject.h @@ -64,7 +64,7 @@ class KX_FontObject : public KX_GameObject const MT_Vector2 GetTextDimensions(); protected: - std::vector m_text; + std::vector m_text; Object *m_object; int m_fontid; int m_dpi; diff --git a/source/gameengine/Ketsji/KX_GameActuator.cpp b/source/gameengine/Ketsji/KX_GameActuator.cpp index 9568672ec2c8..a2baef0f58dc 100644 --- a/source/gameengine/Ketsji/KX_GameActuator.cpp +++ b/source/gameengine/Ketsji/KX_GameActuator.cpp @@ -49,8 +49,8 @@ KX_GameActuator::KX_GameActuator(SCA_IObject *gameobj, int mode, - const STR_String& filename, - const STR_String& loadinganimationname, + const std::string& filename, + const std::string& loadinganimationname, SCA_IScene* scene, KX_KetsjiEngine* ketsjiengine) : SCA_IActuator(gameobj, KX_ACT_GAME) @@ -97,7 +97,7 @@ bool KX_GameActuator::Update() { if (m_ketsjiengine) { - STR_String exitstring = "start other game"; + std::string exitstring = "start other game"; m_ketsjiengine->RequestExit(KX_EXIT_REQUEST_START_OTHER_GAME); m_ketsjiengine->SetNameNextGame(m_filename); m_scene->AddDebugProperty((this)->GetParent(), exitstring); @@ -109,7 +109,7 @@ bool KX_GameActuator::Update() { if (m_ketsjiengine) { - STR_String exitstring = "restarting game"; + std::string exitstring = "restarting game"; m_ketsjiengine->RequestExit(KX_EXIT_REQUEST_RESTART_GAME); m_ketsjiengine->SetNameNextGame(m_filename); m_scene->AddDebugProperty((this)->GetParent(), exitstring); @@ -120,7 +120,7 @@ bool KX_GameActuator::Update() { if (m_ketsjiengine) { - STR_String exitstring = "quiting game"; + std::string exitstring = "quiting game"; m_ketsjiengine->RequestExit(KX_EXIT_REQUEST_QUIT_GAME); m_scene->AddDebugProperty((this)->GetParent(), exitstring); } @@ -200,7 +200,7 @@ PyMethodDef KX_GameActuator::Methods[] = PyAttributeDef KX_GameActuator::Attributes[] = { KX_PYATTRIBUTE_STRING_RW("fileName",0,100,false,KX_GameActuator,m_filename), KX_PYATTRIBUTE_INT_RW("mode", KX_GAME_NODEF+1, KX_GAME_MAX-1, true, KX_GameActuator, m_mode), - { NULL } //Sentinel + KX_PYATTRIBUTE_NULL //Sentinel }; #endif // WITH_PYTHON diff --git a/source/gameengine/Ketsji/KX_GameActuator.h b/source/gameengine/Ketsji/KX_GameActuator.h index 57472836bb24..8ccd549ea4b7 100644 --- a/source/gameengine/Ketsji/KX_GameActuator.h +++ b/source/gameengine/Ketsji/KX_GameActuator.h @@ -44,8 +44,8 @@ class KX_GameActuator : public SCA_IActuator protected: int m_mode; bool m_restart; - STR_String m_filename; - STR_String m_loadinganimationname; + std::string m_filename; + std::string m_loadinganimationname; class SCA_IScene* m_scene; class KX_KetsjiEngine* m_ketsjiengine; @@ -66,8 +66,8 @@ class KX_GameActuator : public SCA_IActuator KX_GameActuator(SCA_IObject* gameobj, int mode, - const STR_String& filename, - const STR_String& loadinganimationname, + const std::string& filename, + const std::string& loadinganimationname, SCA_IScene* scene, KX_KetsjiEngine* ketsjiEngine); virtual ~KX_GameActuator(); diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 549991a10973..e428b6a53d1f 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -221,18 +221,18 @@ KX_GameObject* KX_GameObject::GetClientObject(KX_ClientObjectInfo *info) return info->m_gameobject; } -const STR_String KX_GameObject::GetText() +const std::string KX_GameObject::GetText() { return m_text; } -STR_String KX_GameObject::GetName() +std::string KX_GameObject::GetName() { return m_name; } /* Set the name of the value */ -void KX_GameObject::SetName(const char *name) +void KX_GameObject::SetName(const std::string& name) { m_name = name; } @@ -441,7 +441,7 @@ BL_ActionManager* KX_GameObject::GetActionManager() return m_actionManager; } -bool KX_GameObject::PlayAction(const char* name, +bool KX_GameObject::PlayAction(const std::string& name, float start, float end, short layer, @@ -486,7 +486,7 @@ float KX_GameObject::GetActionFrame(short layer) return GetActionManager()->GetActionFrame(layer); } -const char *KX_GameObject::GetActionName(short layer) +const std::string KX_GameObject::GetActionName(short layer) { return GetActionManager()->GetActionName(layer); } @@ -2005,7 +2005,7 @@ PyAttributeDef KX_GameObject::Attributes[] = { KX_PYATTRIBUTE_RO_FUNCTION("sensors", KX_GameObject, pyattr_get_sensors), KX_PYATTRIBUTE_RO_FUNCTION("controllers", KX_GameObject, pyattr_get_controllers), KX_PYATTRIBUTE_RO_FUNCTION("actuators", KX_GameObject, pyattr_get_actuators), - {NULL} //Sentinel + KX_PYATTRIBUTE_NULL //Sentinel }; PyObject *KX_GameObject::PyReplaceMesh(PyObject *args) @@ -2265,7 +2265,7 @@ PyTypeObject KX_GameObject::Type = { PyObject *KX_GameObject::pyattr_get_name(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { KX_GameObject* self = static_cast(self_v); - return PyUnicode_From_STR_String(self->GetName()); + return PyUnicode_FromStdString(self->GetName()); } int KX_GameObject::pyattr_set_name(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) @@ -2277,8 +2277,8 @@ int KX_GameObject::pyattr_set_name(void *self_v, const KX_PYATTRIBUTE_DEF *attrd return PY_SET_ATTR_FAIL; } - STR_String newname = STR_String(_PyUnicode_AsString(value)); - STR_String oldname = self->GetName(); + std::string newname = std::string(_PyUnicode_AsString(value)); + std::string oldname = self->GetName(); SCA_LogicManager *manager = self->GetScene()->GetLogicManager(); @@ -2287,7 +2287,7 @@ int KX_GameObject::pyattr_set_name(void *self_v, const KX_PYATTRIBUTE_DEF *attrd /* Two non-replica objects can have the same name bacause these objects are register in the * logic manager and that the result of GetGameObjectByName will be undefined. */ if (manager->GetGameObjectByName(newname)) { - PyErr_Format(PyExc_TypeError, "gameOb.name = str: name %s is already used by an other non-replica game object", oldname.ReadPtr()); + PyErr_Format(PyExc_TypeError, "gameOb.name = str: name %s is already used by an other non-replica game object", oldname.c_str()); return PY_SET_ATTR_FAIL; } // Unregister the old name. @@ -3087,9 +3087,9 @@ static PyObject *kx_game_object_get_sensors_item_cb(void *self_v, int index) return ((KX_GameObject *)self_v)->GetSensors()[index]->GetProxy(); } -static const char *kx_game_object_get_sensors_item_name_cb(void *self_v, int index) +static const std::string kx_game_object_get_sensors_item_name_cb(void *self_v, int index) { - return ((KX_GameObject *)self_v)->GetSensors()[index]->GetName().ReadPtr(); + return ((KX_GameObject *)self_v)->GetSensors()[index]->GetName(); } /* These are experimental! */ @@ -3114,9 +3114,9 @@ static PyObject *kx_game_object_get_controllers_item_cb(void *self_v, int index) return ((KX_GameObject *)self_v)->GetControllers()[index]->GetProxy(); } -static const char *kx_game_object_get_controllers_item_name_cb(void *self_v, int index) +static const std::string kx_game_object_get_controllers_item_name_cb(void *self_v, int index) { - return ((KX_GameObject *)self_v)->GetControllers()[index]->GetName().ReadPtr(); + return ((KX_GameObject *)self_v)->GetControllers()[index]->GetName(); } PyObject *KX_GameObject::pyattr_get_controllers(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) @@ -3140,9 +3140,9 @@ static PyObject *kx_game_object_get_actuators_item_cb(void *self_v, int index) return ((KX_GameObject *)self_v)->GetActuators()[index]->GetProxy(); } -static const char *kx_game_object_get_actuators_item_name_cb(void *self_v, int index) +static const std::string kx_game_object_get_actuators_item_name_cb(void *self_v, int index) { - return ((KX_GameObject *)self_v)->GetActuators()[index]->GetName().ReadPtr(); + return ((KX_GameObject *)self_v)->GetActuators()[index]->GetName(); } PyObject *KX_GameObject::pyattr_get_actuators(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) @@ -3678,7 +3678,7 @@ KX_PYMETHODDEF_DOC_O(KX_GameObject, getVectTo, struct KX_GameObject::RayCastData { - RayCastData(STR_String prop, bool xray, unsigned int mask) + RayCastData(std::string prop, bool xray, unsigned int mask) :m_prop(prop), m_xray(xray), m_mask(mask), @@ -3686,7 +3686,7 @@ struct KX_GameObject::RayCastData { } - STR_String m_prop; + std::string m_prop; bool m_xray; unsigned int m_mask; KX_GameObject *m_hitObject; @@ -3698,7 +3698,7 @@ bool KX_GameObject::RayHit(KX_ClientObjectInfo *client, KX_RayCast *result, RayC // if X-ray option is selected, the unwnted objects were not tested, so get here only with true hit // if not, all objects were tested and the front one may not be the correct one. - if ((rayData->m_xray || rayData->m_prop.Length() == 0 || hitKXObj->GetProperty(rayData->m_prop) != NULL) && + if ((rayData->m_xray || rayData->m_prop.size() == 0 || hitKXObj->GetProperty(rayData->m_prop) != NULL) && hitKXObj->GetUserCollisionGroup() & rayData->m_mask) { rayData->m_hitObject = hitKXObj; @@ -3726,7 +3726,7 @@ bool KX_GameObject::NeedRayCast(KX_ClientObjectInfo *client, RayCastData *rayDat // if X-Ray option is selected, skip object that don't match the criteria as we see through them // if not, test all objects because we don't know yet which one will be on front - if ((!rayData->m_xray || rayData->m_prop.Length() == 0 || hitKXObj->GetProperty(rayData->m_prop) != NULL) && + if ((!rayData->m_xray || rayData->m_prop.size() == 0 || hitKXObj->GetProperty(rayData->m_prop) != NULL) && hitKXObj->GetUserCollisionGroup() & rayData->m_mask) { return true; @@ -3744,7 +3744,7 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCastTo, MT_Vector3 toPoint; PyObject *pyarg; float dist = 0.0f; - char *propName = NULL; + const char *propName = ""; SCA_LogicManager *logicmgr = GetScene()->GetLogicManager(); if (!PyArg_ParseTuple(args,"O|fs:rayCastTo", &pyarg, &dist, &propName)) { @@ -3858,7 +3858,7 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCast, PyObject *pyto; PyObject *pyfrom = NULL; float dist = 0.0f; - char *propName = NULL; + const char *propName = ""; KX_GameObject *other; int face=0, xray=0, poly=0; int mask = (1 << OB_MAX_COL_MASKS) - 1; @@ -4089,7 +4089,7 @@ KX_PYMETHODDEF_DOC(KX_GameObject, getActionName, layer_check(layer, "getActionName"); - return PyUnicode_FromString(GetActionName(layer)); + return PyUnicode_FromStdString(GetActionName(layer)); } KX_PYMETHODDEF_DOC(KX_GameObject, setActionFrame, @@ -4201,7 +4201,7 @@ bool ConvertPythonToGameObject(SCA_LogicManager *manager, PyObject *value, KX_Ga } if (PyUnicode_Check(value)) { - *object = (KX_GameObject*)manager->GetGameObjectByName(STR_String( _PyUnicode_AsString(value) )); + *object = (KX_GameObject*)manager->GetGameObjectByName(std::string( _PyUnicode_AsString(value) )); if (*object) { return true; diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h index 59e9b7b50c44..490c12d8154f 100644 --- a/source/gameengine/Ketsji/KX_GameObject.h +++ b/source/gameengine/Ketsji/KX_GameObject.h @@ -84,8 +84,8 @@ class KX_GameObject : public SCA_IObject protected: KX_ClientObjectInfo* m_pClient_info; - STR_String m_name; - STR_String m_text; + std::string m_name; + std::string m_text; int m_layer; std::vector m_meshes; KX_LodManager *m_lodManager; @@ -263,7 +263,7 @@ class KX_GameObject : public SCA_IObject /** * Adds an action to the object's action manager */ - bool PlayAction(const char* name, + bool PlayAction(const std::string& name, float start, float end, short layer=0, @@ -283,7 +283,7 @@ class KX_GameObject : public SCA_IObject /** * Gets the name of the current action */ - const char *GetActionName(short layer); + const std::string GetActionName(short layer); /** * Sets the current frame of an action @@ -360,7 +360,7 @@ class KX_GameObject : public SCA_IObject /** * Inherited from CValue */ - virtual const STR_String GetText(); + virtual const std::string GetText(); /** * \section Inherited from CValue. These are the useful @@ -370,12 +370,12 @@ class KX_GameObject : public SCA_IObject /** * Inherited from CValue -- returns the name of this object. */ - virtual STR_String GetName(); + virtual std::string GetName(); /** * Inherited from CValue -- set the name of this object. */ - virtual void SetName(const char *name); + virtual void SetName(const std::string& name); /** * Inherited from CValue -- return a new copy of this @@ -928,7 +928,7 @@ class KX_GameObject : public SCA_IObject */ virtual PyObject *py_repr(void) { - return PyUnicode_From_STR_String(GetName()); + return PyUnicode_FromStdString(GetName()); } KX_PYMETHOD_O(KX_GameObject,SetWorldPosition); diff --git a/source/gameengine/Ketsji/KX_Globals.cpp b/source/gameengine/Ketsji/KX_Globals.cpp index 78692c999c69..07add265bc6d 100644 --- a/source/gameengine/Ketsji/KX_Globals.cpp +++ b/source/gameengine/Ketsji/KX_Globals.cpp @@ -34,8 +34,8 @@ extern "C" { static KX_KetsjiEngine *g_engine = NULL; static KX_Scene *g_scene = NULL; -static STR_String g_mainPath = ""; -static STR_String g_origPath = ""; +static std::string g_mainPath = ""; +static std::string g_origPath = ""; void KX_SetActiveEngine(KX_KetsjiEngine *engine) { @@ -47,20 +47,20 @@ void KX_SetActiveScene(KX_Scene *scene) g_scene = scene; } -void KX_SetMainPath(const STR_String& path) +void KX_SetMainPath(const std::string& path) { char cpath[FILE_MAX]; - BLI_strncpy(cpath, path.ReadPtr(), sizeof(cpath)); + BLI_strncpy(cpath, path.c_str(), sizeof(cpath)); BLI_cleanup_file(NULL, cpath); - g_mainPath = STR_String(cpath); + g_mainPath = std::string(cpath); } -void KX_SetOrigPath(const STR_String& path) +void KX_SetOrigPath(const std::string& path) { char cpath[FILE_MAX]; - BLI_strncpy(cpath, path.ReadPtr(), sizeof(cpath)); + BLI_strncpy(cpath, path.c_str(), sizeof(cpath)); BLI_cleanup_file(NULL, cpath); - g_origPath = STR_String(cpath); + g_origPath = std::string(cpath); } KX_KetsjiEngine *KX_GetActiveEngine() @@ -73,12 +73,12 @@ KX_Scene *KX_GetActiveScene() return g_scene; } -const STR_String& KX_GetMainPath() +const std::string& KX_GetMainPath() { return g_mainPath; } -const STR_String& KX_GetOrigPath() +const std::string& KX_GetOrigPath() { return g_origPath; } diff --git a/source/gameengine/Ketsji/KX_Globals.h b/source/gameengine/Ketsji/KX_Globals.h index 9702a44e9661..4de44b56af31 100644 --- a/source/gameengine/Ketsji/KX_Globals.h +++ b/source/gameengine/Ketsji/KX_Globals.h @@ -29,20 +29,20 @@ #include "MT_Vector3.h" #include "MT_Vector4.h" -#include "STR_String.h" +#include class KX_KetsjiEngine; class KX_Scene; void KX_SetActiveEngine(KX_KetsjiEngine *engine); void KX_SetActiveScene(KX_Scene *scene); -void KX_SetMainPath(const STR_String& path); -void KX_SetOrigPath(const STR_String& path); +void KX_SetMainPath(const std::string& path); +void KX_SetOrigPath(const std::string& path); KX_KetsjiEngine *KX_GetActiveEngine(); KX_Scene *KX_GetActiveScene(); -const STR_String& KX_GetMainPath(); -const STR_String& KX_GetOrigPath(); +const std::string& KX_GetMainPath(); +const std::string& KX_GetOrigPath(); void KX_RasterizerDrawDebugLine(const MT_Vector3 &from,const MT_Vector3 &to,const MT_Vector4 &color); void KX_RasterizerDrawDebugCircle(const MT_Vector3 ¢er, const MT_Scalar radius, const MT_Vector4 &color, diff --git a/source/gameengine/Ketsji/KX_ISceneConverter.h b/source/gameengine/Ketsji/KX_ISceneConverter.h index fa388d05e745..fc83f87a00fe 100644 --- a/source/gameengine/Ketsji/KX_ISceneConverter.h +++ b/source/gameengine/Ketsji/KX_ISceneConverter.h @@ -32,7 +32,7 @@ #ifndef __KX_ISCENECONVERTER_H__ #define __KX_ISCENECONVERTER_H__ -#include "STR_String.h" +#include #include "EXP_Python.h" #ifdef WITH_CXX_GUARDEDALLOC @@ -69,10 +69,10 @@ class KX_ISceneConverter virtual void SetAlwaysUseExpandFraming(bool to_what) = 0; - virtual void SetNewFileName(const STR_String& filename) = 0; + virtual void SetNewFileName(const std::string& filename) = 0; virtual bool TryAndLoadNewFile() = 0; - virtual struct Scene* GetBlenderSceneForName(const STR_String& name)=0; + virtual struct Scene* GetBlenderSceneForName(const std::string& name)=0; virtual CListValue *GetInactiveSceneNames() = 0; #ifdef WITH_CXX_GUARDEDALLOC diff --git a/source/gameengine/Ketsji/KX_IpoConvert.cpp b/source/gameengine/Ketsji/KX_IpoConvert.cpp index efa6e5aea077..40c26e4e7b28 100644 --- a/source/gameengine/Ketsji/KX_IpoConvert.cpp +++ b/source/gameengine/Ketsji/KX_IpoConvert.cpp @@ -69,7 +69,7 @@ #include "SG_Node.h" -#include "STR_HashedString.h" +#include static BL_InterpolatorList *GetAdtList(struct bAction *for_act, KX_BlenderSceneConverter *converter) { diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp index 299d5eb592b6..ebe08c22e8d3 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp @@ -36,6 +36,8 @@ #include "CM_Message.h" +#include + #include "BLI_task.h" #include "KX_KetsjiEngine.h" @@ -704,7 +706,7 @@ void KX_KetsjiEngine::RequestExit(int exitrequestmode) m_exitcode = exitrequestmode; } -void KX_KetsjiEngine::SetNameNextGame(const STR_String& nextgame) +void KX_KetsjiEngine::SetNameNextGame(const std::string& nextgame) { m_exitstring = nextgame; } @@ -720,12 +722,12 @@ int KX_KetsjiEngine::GetExitCode() return m_exitcode; } -const STR_String& KX_KetsjiEngine::GetExitString() +const std::string& KX_KetsjiEngine::GetExitString() { return m_exitstring; } -void KX_KetsjiEngine::EnableCameraOverride(const STR_String& forscene) +void KX_KetsjiEngine::EnableCameraOverride(const std::string& forscene) { m_overrideCam = true; m_overrideSceneName = forscene; @@ -1162,7 +1164,7 @@ void KX_KetsjiEngine::PostProcessScene(KX_Scene *scene) void KX_KetsjiEngine::RenderDebugProperties() { - STR_String debugtxt; + std::string debugtxt; int title_xmargin = -7; int title_y_top_margin = 4; int title_y_bottom_margin = 2; @@ -1204,9 +1206,9 @@ void KX_KetsjiEngine::RenderDebugProperties() m_canvas->GetWidth() /* RdV, TODO ?? */, m_canvas->GetHeight() /* RdV, TODO ?? */); - debugtxt.Format("%5.2fms (%.1ffps)", tottime * 1000.0f, 1.0f / tottime); + debugtxt = (boost::format("%5.2fms (%.1ffps)") % (tottime * 1000.0f) % (1.0f / tottime)).str(); m_rasterizer->RenderText2D(RAS_IRasterizer::RAS_TEXT_PADDED, - debugtxt.ReadPtr(), + debugtxt, xcoord + const_xindent + profile_indent, ycoord, m_canvas->GetWidth() /* RdV, TODO ?? */, @@ -1227,9 +1229,9 @@ void KX_KetsjiEngine::RenderDebugProperties() double time = m_logger->GetAverage((KX_TimeCategory)j); - debugtxt.Format("%5.2fms | %d%%", time*1000.f, (int)(time/tottime * 100.f)); + debugtxt = (boost::format("%5.2fms | %d%%") % (time*1000.f) % (int)(time/tottime * 100.f)).str(); m_rasterizer->RenderText2D(RAS_IRasterizer::RAS_TEXT_PADDED, - debugtxt.ReadPtr(), + debugtxt, xcoord + const_xindent + profile_indent, ycoord, m_canvas->GetWidth(), m_canvas->GetHeight()); @@ -1268,8 +1270,8 @@ void KX_KetsjiEngine::RenderDebugProperties() for (unsigned i = 0; i < debugproplist.size() && propsAct < propsMax; i++) { CValue *propobj = debugproplist[i]->m_obj; - STR_String objname = propobj->GetName(); - STR_String propname = debugproplist[i]->m_name; + std::string objname = propobj->GetName(); + std::string propname = debugproplist[i]->m_name; propsAct++; if (propname == "__state__") { // reserve name for object state @@ -1282,12 +1284,12 @@ void KX_KetsjiEngine::RenderDebugProperties() if (!first) { debugtxt += ","; } - debugtxt += STR_String(statenum); + debugtxt += std::to_string(statenum); first = false; } } m_rasterizer->RenderText2D(RAS_IRasterizer::RAS_TEXT_PADDED, - debugtxt.ReadPtr(), + debugtxt, xcoord + const_xindent, ycoord, m_canvas->GetWidth(), @@ -1297,10 +1299,10 @@ void KX_KetsjiEngine::RenderDebugProperties() else { CValue *propval = propobj->GetProperty(propname); if (propval) { - STR_String text = propval->GetText(); + std::string text = propval->GetText(); debugtxt = objname + ": '" + propname + "' = " + text; m_rasterizer->RenderText2D(RAS_IRasterizer::RAS_TEXT_PADDED, - debugtxt.ReadPtr(), + debugtxt, xcoord + const_xindent, ycoord, m_canvas->GetWidth(), @@ -1318,12 +1320,12 @@ CListValue *KX_KetsjiEngine::CurrentScenes() return m_scenes; } -KX_Scene *KX_KetsjiEngine::FindScene(const STR_String& scenename) +KX_Scene *KX_KetsjiEngine::FindScene(const std::string& scenename) { return (KX_Scene *)m_scenes->FindValue(scenename); } -void KX_KetsjiEngine::ConvertAndAddScene(const STR_String& scenename, bool overlay) +void KX_KetsjiEngine::ConvertAndAddScene(const std::string& scenename, bool overlay) { // only add scene when it doesn't exist! if (FindScene(scenename)) { @@ -1339,7 +1341,7 @@ void KX_KetsjiEngine::ConvertAndAddScene(const STR_String& scenename, bool overl } } -void KX_KetsjiEngine::RemoveScene(const STR_String& scenename) +void KX_KetsjiEngine::RemoveScene(const std::string& scenename) { if (FindScene(scenename)) { m_removingScenes.push_back(scenename); @@ -1352,9 +1354,9 @@ void KX_KetsjiEngine::RemoveScene(const STR_String& scenename) void KX_KetsjiEngine::RemoveScheduledScenes() { if (m_removingScenes.size()) { - std::vector::iterator scenenameit; + std::vector::iterator scenenameit; for (scenenameit = m_removingScenes.begin(); scenenameit != m_removingScenes.end(); scenenameit++) { - STR_String scenename = *scenenameit; + std::string scenename = *scenenameit; KX_Scene *scene = FindScene(scenename); if (scene) { @@ -1382,7 +1384,7 @@ KX_Scene *KX_KetsjiEngine::CreateScene(Scene *scene, bool libloading) return tmpscene; } -KX_Scene *KX_KetsjiEngine::CreateScene(const STR_String& scenename) +KX_Scene *KX_KetsjiEngine::CreateScene(const std::string& scenename) { Scene *scene = m_sceneconverter->GetBlenderSceneForName(scenename); if (!scene) @@ -1393,14 +1395,14 @@ KX_Scene *KX_KetsjiEngine::CreateScene(const STR_String& scenename) void KX_KetsjiEngine::AddScheduledScenes() { - std::vector::iterator scenenameit; + std::vector::iterator scenenameit; if (m_addingOverlayScenes.size()) { for (scenenameit = m_addingOverlayScenes.begin(); scenenameit != m_addingOverlayScenes.end(); scenenameit++) { - STR_String scenename = *scenenameit; + std::string scenename = *scenenameit; KX_Scene *tmpscene = CreateScene(scenename); if (tmpscene) { m_scenes->Add(tmpscene->AddRef()); @@ -1419,7 +1421,7 @@ void KX_KetsjiEngine::AddScheduledScenes() scenenameit != m_addingBackgroundScenes.end(); scenenameit++) { - STR_String scenename = *scenenameit; + std::string scenename = *scenenameit; KX_Scene *tmpscene = CreateScene(scenename); if (tmpscene) { m_scenes->Insert(0, tmpscene->AddRef()); @@ -1434,7 +1436,7 @@ void KX_KetsjiEngine::AddScheduledScenes() } } -bool KX_KetsjiEngine::ReplaceScene(const STR_String& oldscene, const STR_String& newscene) +bool KX_KetsjiEngine::ReplaceScene(const std::string& oldscene, const std::string& newscene) { // Don't allow replacement if the new scene doesn't exist. // Allows smarter game design (used to have no check here). @@ -1457,14 +1459,14 @@ bool KX_KetsjiEngine::ReplaceScene(const STR_String& oldscene, const STR_String& void KX_KetsjiEngine::ReplaceScheduledScenes() { if (m_replace_scenes.size()) { - std::vector >::iterator scenenameit; + std::vector >::iterator scenenameit; for (scenenameit = m_replace_scenes.begin(); scenenameit != m_replace_scenes.end(); scenenameit++) { - STR_String oldscenename = (*scenenameit).first; - STR_String newscenename = (*scenenameit).second; + std::string oldscenename = (*scenenameit).first; + std::string newscenename = (*scenenameit).second; /* Scenes are not supposed to be included twice... I think */ for (unsigned int sce_idx = 0; sce_idx < m_scenes->GetCount(); ++sce_idx) { KX_Scene *scene = (KX_Scene *)m_scenes->GetValue(sce_idx); @@ -1489,7 +1491,7 @@ void KX_KetsjiEngine::ReplaceScheduledScenes() } } -void KX_KetsjiEngine::SuspendScene(const STR_String& scenename) +void KX_KetsjiEngine::SuspendScene(const std::string& scenename) { KX_Scene *scene = FindScene(scenename); if (scene) { @@ -1497,7 +1499,7 @@ void KX_KetsjiEngine::SuspendScene(const STR_String& scenename) } } -void KX_KetsjiEngine::ResumeScene(const STR_String& scenename) +void KX_KetsjiEngine::ResumeScene(const std::string& scenename) { KX_Scene *scene = FindScene(scenename); if (scene) { diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.h b/source/gameengine/Ketsji/KX_KetsjiEngine.h index efabd119c2d2..4d94c13d4463 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.h +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.h @@ -35,7 +35,7 @@ #include "MT_CmMatrix4x4.h" #include "MT_Matrix4x4.h" -#include "STR_String.h" +#include #include "KX_ISystem.h" #include "KX_Scene.h" #include "EXP_Python.h" @@ -93,13 +93,13 @@ class KX_KetsjiEngine SCA_IInputDevice *m_inputDevice; /// Lists of scenes scheduled to be removed at the end of the frame. - std::vector m_removingScenes; + std::vector m_removingScenes; /// Lists of overley scenes scheduled to be added at the end of the frame. - std::vector m_addingOverlayScenes; + std::vector m_addingOverlayScenes; /// Lists of background scenes scheduled to be added at the end of the frame. - std::vector m_addingBackgroundScenes; + std::vector m_addingBackgroundScenes; /// Lists of scenes scheduled to be replaced at the end of the frame. - std::vector > m_replace_scenes; + std::vector > m_replace_scenes; /// The current list of scenes. CListValue *m_scenes; @@ -146,12 +146,12 @@ class KX_KetsjiEngine static short m_exitkey; int m_exitcode; - STR_String m_exitstring; + std::string m_exitstring; float m_cameraZoom; bool m_overrideCam; - STR_String m_overrideSceneName; + std::string m_overrideSceneName; bool m_overrideCamUseOrtho; MT_CmMatrix4x4 m_overrideCamProjMat; @@ -294,29 +294,29 @@ class KX_KetsjiEngine void StartEngine(bool clearIpo); void StopEngine(); - void Export(const STR_String& filename); + void Export(const std::string& filename); void RequestExit(int exitrequestmode); - void SetNameNextGame(const STR_String& nextgame); + void SetNameNextGame(const std::string& nextgame); int GetExitCode(); - const STR_String& GetExitString(); + const std::string& GetExitString(); CListValue *CurrentScenes(); - KX_Scene *FindScene(const STR_String& scenename); + KX_Scene *FindScene(const std::string& scenename); void AddScene(KX_Scene *scene); - void ConvertAndAddScene(const STR_String& scenename, bool overlay); + void ConvertAndAddScene(const std::string& scenename, bool overlay); - void RemoveScene(const STR_String& scenename); - bool ReplaceScene(const STR_String& oldscene, const STR_String& newscene); - void SuspendScene(const STR_String& scenename); - void ResumeScene(const STR_String& scenename); + void RemoveScene(const std::string& scenename); + bool ReplaceScene(const std::string& oldscene, const std::string& newscene); + void SuspendScene(const std::string& scenename); + void ResumeScene(const std::string& scenename); void GetSceneViewport(KX_Scene *scene, KX_Camera *cam, RAS_Rect& area, RAS_Rect& viewport); /// Sets zoom for camera objects, useful only with extend and scale framing mode. void SetCameraZoom(float camzoom); - void EnableCameraOverride(const STR_String& forscene); + void EnableCameraOverride(const std::string& forscene); void SetCameraOverrideUseOrtho(bool useOrtho); void SetCameraOverrideProjectionMatrix(const MT_CmMatrix4x4& mat); @@ -559,7 +559,7 @@ class KX_KetsjiEngine */ void GetOverrideFrameColor(float& r, float& g, float& b, float& a) const; - KX_Scene *CreateScene(const STR_String& scenename); + KX_Scene *CreateScene(const std::string& scenename); KX_Scene *CreateScene(Scene *scene, bool libloading = false); GlobalSettings *GetGlobalSettings(void); diff --git a/source/gameengine/Ketsji/KX_Light.cpp b/source/gameengine/Ketsji/KX_Light.cpp index 3c34c8c4f3c3..b5aff943b1d1 100644 --- a/source/gameengine/Ketsji/KX_Light.cpp +++ b/source/gameengine/Ketsji/KX_Light.cpp @@ -170,7 +170,7 @@ PyAttributeDef KX_LightObject::Attributes[] = { KX_PYATTRIBUTE_RO_FUNCTION("HEMI", KX_LightObject, pyattr_get_typeconst), KX_PYATTRIBUTE_RW_FUNCTION("type", KX_LightObject, pyattr_get_type, pyattr_set_type), KX_PYATTRIBUTE_RW_FUNCTION("staticShadow", KX_LightObject, pyattr_get_static_shadow, pyattr_set_static_shadow), - {NULL} // Sentinel + KX_PYATTRIBUTE_NULL // Sentinel }; KX_PYMETHODDEF_DOC_NOARGS(KX_LightObject, updateShadow, "updateShadow(): Set the shadow to be updated next frame if the lamp uses a static shadow.\n") @@ -191,16 +191,16 @@ int KX_LightObject::pyattr_set_layer(void *self_v, const KX_PYATTRIBUTE_DEF *att int layer = PyLong_AsLong(value); if (layer == -1 && PyErr_Occurred()) { - PyErr_Format(PyExc_TypeError, "expected an integer for attribute \"%s\"", attrdef->m_name); + PyErr_Format(PyExc_TypeError, "expected an integer for attribute \"%s\"", attrdef->m_name.c_str()); return PY_SET_ATTR_FAIL; } if (layer < 1) { - PyErr_Format(PyExc_TypeError, "expected an integer greater than 1 for attribute \"%s\"", attrdef->m_name); + PyErr_Format(PyExc_TypeError, "expected an integer greater than 1 for attribute \"%s\"", attrdef->m_name.c_str()); return PY_SET_ATTR_FAIL; } else if (layer > MAX_LIGHT_LAYERS) { - PyErr_Format(PyExc_TypeError, "expected an integer less than %i for attribute \"%s\"", MAX_LIGHT_LAYERS, attrdef->m_name); + PyErr_Format(PyExc_TypeError, "expected an integer less than %i for attribute \"%s\"", MAX_LIGHT_LAYERS, attrdef->m_name.c_str()); return PY_SET_ATTR_FAIL; } @@ -229,7 +229,7 @@ int KX_LightObject::pyattr_set_energy(void *self_v, const KX_PYATTRIBUTE_DEF *at return PY_SET_ATTR_SUCCESS; } - PyErr_Format(PyExc_TypeError, "expected float value for attribute \"%s\"", attrdef->m_name); + PyErr_Format(PyExc_TypeError, "expected float value for attribute \"%s\"", attrdef->m_name.c_str()); return PY_SET_ATTR_FAIL; } @@ -314,7 +314,7 @@ int KX_LightObject::pyattr_set_distance(void *self_v, const KX_PYATTRIBUTE_DEF * return PY_SET_ATTR_SUCCESS; } - PyErr_Format(PyExc_TypeError, "expected float value for attribute \"%s\"", attrdef->m_name); + PyErr_Format(PyExc_TypeError, "expected float value for attribute \"%s\"", attrdef->m_name.c_str()); return PY_SET_ATTR_FAIL; } @@ -357,7 +357,7 @@ int KX_LightObject::pyattr_set_lin_attenuation(void *self_v, const KX_PYATTRIBUT return PY_SET_ATTR_SUCCESS; } - PyErr_Format(PyExc_TypeError, "expected float value for attribute \"%s\"", attrdef->m_name); + PyErr_Format(PyExc_TypeError, "expected float value for attribute \"%s\"", attrdef->m_name.c_str()); return PY_SET_ATTR_FAIL; } @@ -382,7 +382,7 @@ int KX_LightObject::pyattr_set_quad_attenuation(void *self_v, const KX_PYATTRIBU return PY_SET_ATTR_SUCCESS; } - PyErr_Format(PyExc_TypeError, "expected float value for attribute \"%s\"", attrdef->m_name); + PyErr_Format(PyExc_TypeError, "expected float value for attribute \"%s\"", attrdef->m_name.c_str()); return PY_SET_ATTR_FAIL; } @@ -407,7 +407,7 @@ int KX_LightObject::pyattr_set_spotsize(void *self_v, const KX_PYATTRIBUTE_DEF * return PY_SET_ATTR_SUCCESS; } - PyErr_Format(PyExc_TypeError, "expected float value for attribute \"%s\"", attrdef->m_name); + PyErr_Format(PyExc_TypeError, "expected float value for attribute \"%s\"", attrdef->m_name.c_str()); return PY_SET_ATTR_FAIL; } PyObject *KX_LightObject::pyattr_get_spotblend(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) @@ -431,7 +431,7 @@ int KX_LightObject::pyattr_set_spotblend(void *self_v, const KX_PYATTRIBUTE_DEF return PY_SET_ATTR_SUCCESS; } - PyErr_Format(PyExc_TypeError, "expected float value for attribute \"%s\"", attrdef->m_name); + PyErr_Format(PyExc_TypeError, "expected float value for attribute \"%s\"", attrdef->m_name.c_str()); return PY_SET_ATTR_FAIL; } @@ -439,18 +439,18 @@ PyObject *KX_LightObject::pyattr_get_typeconst(void *self_v, const KX_PYATTRIBUT { PyObject *retvalue; - const char *type = attrdef->m_name; + const std::string& type = attrdef->m_name; - if (!strcmp(type, "SPOT")) { + if (type == "SPOT") { retvalue = PyLong_FromLong(RAS_ILightObject::LIGHT_SPOT); } - else if (!strcmp(type, "SUN")) { + else if (type == "SUN") { retvalue = PyLong_FromLong(RAS_ILightObject::LIGHT_SUN); } - else if (!strcmp(type, "NORMAL")) { + else if (type == "NORMAL") { retvalue = PyLong_FromLong(RAS_ILightObject::LIGHT_NORMAL); } - else if (!strcmp(type, "HEMI")) { + else if (type == "HEMI") { retvalue = PyLong_FromLong(RAS_ILightObject::LIGHT_HEMI); } else { diff --git a/source/gameengine/Ketsji/KX_LodLevel.cpp b/source/gameengine/Ketsji/KX_LodLevel.cpp index c8da18081413..18c07cb7f469 100644 --- a/source/gameengine/Ketsji/KX_LodLevel.cpp +++ b/source/gameengine/Ketsji/KX_LodLevel.cpp @@ -101,7 +101,7 @@ PyAttributeDef KX_LodLevel::Attributes[] = { KX_PYATTRIBUTE_RO_FUNCTION("useHysteresis", KX_LodLevel, pyattr_get_use_hysteresis), KX_PYATTRIBUTE_RO_FUNCTION("useMesh", KX_LodLevel, pyattr_get_use_mesh), KX_PYATTRIBUTE_RO_FUNCTION("useMaterial", KX_LodLevel, pyattr_get_use_material), - {NULL} // Sentinel + KX_PYATTRIBUTE_NULL // Sentinel }; PyObject *KX_LodLevel::pyattr_get_mesh(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) diff --git a/source/gameengine/Ketsji/KX_LodLevel.h b/source/gameengine/Ketsji/KX_LodLevel.h index dc63a1704a3d..393e9d97251a 100644 --- a/source/gameengine/Ketsji/KX_LodLevel.h +++ b/source/gameengine/Ketsji/KX_LodLevel.h @@ -63,7 +63,7 @@ class KX_LodLevel : public PyObjectPlus virtual PyObject *py_repr() { - return PyUnicode_FromString(m_meshobj->GetName()); + return PyUnicode_FromStdString(m_meshobj->GetName()); } static PyObject *pyattr_get_mesh(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); diff --git a/source/gameengine/Ketsji/KX_LodManager.cpp b/source/gameengine/Ketsji/KX_LodManager.cpp index d5e3d4414aeb..69e6ec1dd3e3 100644 --- a/source/gameengine/Ketsji/KX_LodManager.cpp +++ b/source/gameengine/Ketsji/KX_LodManager.cpp @@ -173,7 +173,7 @@ PyMethodDef KX_LodManager::Methods[] = { PyAttributeDef KX_LodManager::Attributes[] = { KX_PYATTRIBUTE_RO_FUNCTION("levels", KX_LodManager, pyattr_get_levels), KX_PYATTRIBUTE_FLOAT_RW("distanceFactor", 0.0f, FLT_MAX, KX_LodManager, m_distanceFactor), - {NULL} //Sentinel + KX_PYATTRIBUTE_NULL }; static int kx_lod_manager_get_levels_size_cb(void *self_v) diff --git a/source/gameengine/Ketsji/KX_MeshProxy.cpp b/source/gameengine/Ketsji/KX_MeshProxy.cpp index a1bb22b68574..db4409749271 100644 --- a/source/gameengine/Ketsji/KX_MeshProxy.cpp +++ b/source/gameengine/Ketsji/KX_MeshProxy.cpp @@ -92,7 +92,7 @@ PyAttributeDef KX_MeshProxy::Attributes[] = { KX_PYATTRIBUTE_RO_FUNCTION("numMaterials", KX_MeshProxy, pyattr_get_numMaterials), KX_PYATTRIBUTE_RO_FUNCTION("polygons", KX_MeshProxy, pyattr_get_polygons), - {NULL} //Sentinel + KX_PYATTRIBUTE_NULL //Sentinel }; KX_MeshProxy::KX_MeshProxy(RAS_MeshObject *mesh) @@ -106,7 +106,7 @@ KX_MeshProxy::~KX_MeshProxy() } // stuff for cvalue related things -STR_String KX_MeshProxy::GetName() +std::string KX_MeshProxy::GetName() { return m_meshobj->GetName(); } @@ -129,7 +129,7 @@ static PyObject *kx_mesh_proxy_get_polygons_item_cb(void *self_v, int index) PyObject *KX_MeshProxy::PyGetMaterialName(PyObject *args, PyObject *kwds) { int matid = 1; - STR_String matname; + std::string matname; if (PyArg_ParseTuple(args, "i:getMaterialName", &matid)) { matname = m_meshobj->GetMaterialName(matid); @@ -138,13 +138,13 @@ PyObject *KX_MeshProxy::PyGetMaterialName(PyObject *args, PyObject *kwds) return NULL; } - return PyUnicode_From_STR_String(matname); + return PyUnicode_FromStdString(matname); } PyObject *KX_MeshProxy::PyGetTextureName(PyObject *args, PyObject *kwds) { int matid = 1; - STR_String matname; + std::string matname; if (PyArg_ParseTuple(args, "i:getTextureName", &matid)) { matname = m_meshobj->GetTextureName(matid); @@ -153,7 +153,7 @@ PyObject *KX_MeshProxy::PyGetTextureName(PyObject *args, PyObject *kwds) return NULL; } - return PyUnicode_From_STR_String(matname); + return PyUnicode_FromStdString(matname); } PyObject *KX_MeshProxy::PyGetVertexArrayLength(PyObject *args, PyObject *kwds) @@ -466,7 +466,7 @@ bool ConvertPythonToMesh(SCA_LogicManager *logicmgr, PyObject *value, RAS_MeshOb } if (PyUnicode_Check(value)) { - *object = (RAS_MeshObject*)logicmgr->GetMeshByName(STR_String(_PyUnicode_AsString(value))); + *object = (RAS_MeshObject*)logicmgr->GetMeshByName(std::string(_PyUnicode_AsString(value))); if (*object) { return true; diff --git a/source/gameengine/Ketsji/KX_MeshProxy.h b/source/gameengine/Ketsji/KX_MeshProxy.h index 397a1f741e69..b253228d6b9f 100644 --- a/source/gameengine/Ketsji/KX_MeshProxy.h +++ b/source/gameengine/Ketsji/KX_MeshProxy.h @@ -58,7 +58,7 @@ class KX_MeshProxy : public CValue } // stuff for cvalue related things - virtual STR_String GetName(); + virtual std::string GetName(); // stuff for python integration diff --git a/source/gameengine/Ketsji/KX_MouseActuator.cpp b/source/gameengine/Ketsji/KX_MouseActuator.cpp index 6df522147a25..c3168571b5aa 100644 --- a/source/gameengine/Ketsji/KX_MouseActuator.cpp +++ b/source/gameengine/Ketsji/KX_MouseActuator.cpp @@ -394,7 +394,7 @@ PyAttributeDef KX_MouseActuator::Attributes[] = { KX_PYATTRIBUTE_RW_FUNCTION("limit_x", KX_MouseActuator, pyattr_get_limit_x, pyattr_set_limit_x), KX_PYATTRIBUTE_RW_FUNCTION("limit_y", KX_MouseActuator, pyattr_get_limit_y, pyattr_set_limit_y), KX_PYATTRIBUTE_RW_FUNCTION("angle", KX_MouseActuator, pyattr_get_angle, pyattr_set_angle), - { NULL } //Sentinel + KX_PYATTRIBUTE_NULL //Sentinel }; PyObject* KX_MouseActuator::pyattr_get_limit_x(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) diff --git a/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp b/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp index 3b7f5ce4cbb9..5d94a3805580 100644 --- a/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp +++ b/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp @@ -65,7 +65,7 @@ KX_MouseFocusSensor::KX_MouseFocusSensor(SCA_MouseManager* eventmgr, short int mousemode, int focusmode, bool bCollisionPulse, - const STR_String& propname, + const std::string& propname, bool bFindMaterial, bool bXRay, KX_Scene* kxscene, @@ -158,7 +158,7 @@ bool KX_MouseFocusSensor::RayHit(KX_ClientObjectInfo *client_info, KX_RayCast *r if ((m_focusmode == 2) || hitKXObj == thisObj) { - if (m_propertyname.Length() == 0) + if (m_propertyname.size() == 0) { bFound = true; } @@ -168,7 +168,7 @@ bool KX_MouseFocusSensor::RayHit(KX_ClientObjectInfo *client_info, KX_RayCast *r for (unsigned int i = 0; i < hitKXObj->GetMeshCount(); ++i) { RAS_MeshObject *meshObj = hitKXObj->GetMesh(i); for (unsigned int j = 0; j < meshObj->NumMaterials(); ++j) { - bFound = strcmp(m_propertyname.ReadPtr(), meshObj->GetMaterialName(j).ReadPtr() + 2) == 0; + bFound = (m_propertyname == std::string(meshObj->GetMaterialName(j), 2)); if (bFound) break; } @@ -207,7 +207,7 @@ bool KX_MouseFocusSensor::NeedRayCast(KX_ClientObjectInfo *client, void *UNUSED( CM_Error("invalid client type " << client->m_type << " found ray casting"); return false; } - if (m_bXRay && m_propertyname.Length() != 0) + if (m_bXRay && m_propertyname.size() != 0) { if (m_bFindMaterial) { @@ -215,7 +215,7 @@ bool KX_MouseFocusSensor::NeedRayCast(KX_ClientObjectInfo *client, void *UNUSED( for (unsigned int i = 0; i < hitKXObj->GetMeshCount(); ++i) { RAS_MeshObject *meshObj = hitKXObj->GetMesh(i); for (unsigned int j = 0; j < meshObj->NumMaterials(); ++j) { - found = strcmp(m_propertyname.ReadPtr(), meshObj->GetMaterialName(j).ReadPtr() + 2) == 0; + found = (m_propertyname == std::string(meshObj->GetMaterialName(j), 2)); if (found) break; } @@ -457,7 +457,7 @@ PyAttributeDef KX_MouseFocusSensor::Attributes[] = { KX_PYATTRIBUTE_BOOL_RW("useXRay", KX_MouseFocusSensor, m_bXRay), KX_PYATTRIBUTE_BOOL_RW("useMaterial", KX_MouseFocusSensor, m_bFindMaterial), KX_PYATTRIBUTE_STRING_RW("propName", 0, MAX_PROP_NAME, false, KX_MouseFocusSensor, m_propertyname), - { NULL } //Sentinel + KX_PYATTRIBUTE_NULL //Sentinel }; /* Attributes */ diff --git a/source/gameengine/Ketsji/KX_MouseFocusSensor.h b/source/gameengine/Ketsji/KX_MouseFocusSensor.h index 69d3f245287b..0e18f0b7a42e 100644 --- a/source/gameengine/Ketsji/KX_MouseFocusSensor.h +++ b/source/gameengine/Ketsji/KX_MouseFocusSensor.h @@ -59,7 +59,7 @@ class KX_MouseFocusSensor : public SCA_MouseSensor short int mousemode, int focusmode, bool bCollisionPulse, - const STR_String& propname, + const std::string& propname, bool bFindMaterial, bool bXRay, KX_Scene* kxscene, @@ -153,7 +153,7 @@ class KX_MouseFocusSensor : public SCA_MouseSensor /** * Property or material name */ - STR_String m_propertyname; + std::string m_propertyname; /** * Flags whether the previous test evaluated positive. diff --git a/source/gameengine/Ketsji/KX_MovementSensor.cpp b/source/gameengine/Ketsji/KX_MovementSensor.cpp index 1fcf9b85fd96..85a2702a5631 100644 --- a/source/gameengine/Ketsji/KX_MovementSensor.cpp +++ b/source/gameengine/Ketsji/KX_MovementSensor.cpp @@ -220,7 +220,7 @@ PyMethodDef KX_MovementSensor::Methods[] = { PyAttributeDef KX_MovementSensor::Attributes[] = { KX_PYATTRIBUTE_FLOAT_RW("threshold", 0.001f, 10000.0f, KX_MovementSensor, m_threshold), KX_PYATTRIBUTE_INT_RW("axis", 0, 6, true, KX_MovementSensor, m_axis), - {NULL} // Sentinel + KX_PYATTRIBUTE_NULL // Sentinel }; #endif diff --git a/source/gameengine/Ketsji/KX_NavMeshObject.cpp b/source/gameengine/Ketsji/KX_NavMeshObject.cpp index 9297648b5c8f..2a0b221355a8 100644 --- a/source/gameengine/Ketsji/KX_NavMeshObject.cpp +++ b/source/gameengine/Ketsji/KX_NavMeshObject.cpp @@ -674,7 +674,7 @@ PyTypeObject KX_NavMeshObject::Type = { }; PyAttributeDef KX_NavMeshObject::Attributes[] = { - { NULL } //Sentinel + KX_PYATTRIBUTE_NULL //Sentinel }; //KX_PYMETHODTABLE_NOARGS(KX_GameObject, getD), diff --git a/source/gameengine/Ketsji/KX_NearSensor.cpp b/source/gameengine/Ketsji/KX_NearSensor.cpp index ffdac96893a3..09ab84316a68 100644 --- a/source/gameengine/Ketsji/KX_NearSensor.cpp +++ b/source/gameengine/Ketsji/KX_NearSensor.cpp @@ -47,7 +47,7 @@ KX_NearSensor::KX_NearSensor(SCA_EventManager* eventmgr, float margin, float resetmargin, bool bFindMaterial, - const STR_String& touchedpropname, + const std::string& touchedpropname, PHY_IPhysicsController* ctrl) :KX_CollisionSensor(eventmgr, gameobj, @@ -197,7 +197,7 @@ bool KX_NearSensor::BroadPhaseFilterCollision(void*obj1,void*obj2) // only take valid colliders if (client_info->m_type == KX_ClientObjectInfo::ACTOR) { - if ((m_touchedpropname.Length() == 0) || + if ((m_touchedpropname.size() == 0) || (gameobj->GetProperty(m_touchedpropname))) { return true; @@ -234,7 +234,7 @@ bool KX_NearSensor::NewHandleCollision(void *obj1, void *obj2, const PHY_CollDat // These checks are done already in BroadPhaseFilterCollision() //if (client_info->m_type == KX_ClientObjectInfo::ACTOR) //{ - // if ((m_touchedpropname.Length() == 0) || + // if ((m_touchedpropname.size() == 0) || // (gameobj->GetProperty(m_touchedpropname))) // { m_bTriggered = true; @@ -286,7 +286,7 @@ PyMethodDef KX_NearSensor::Methods[] = { PyAttributeDef KX_NearSensor::Attributes[] = { KX_PYATTRIBUTE_FLOAT_RW_CHECK("distance", 0, 10000, KX_NearSensor, m_Margin, CheckResetDistance), KX_PYATTRIBUTE_FLOAT_RW_CHECK("resetDistance", 0, 10000, KX_NearSensor, m_ResetMargin, CheckResetDistance), - {NULL} //Sentinel + KX_PYATTRIBUTE_NULL //Sentinel }; #endif // WITH_PYTHON diff --git a/source/gameengine/Ketsji/KX_NearSensor.h b/source/gameengine/Ketsji/KX_NearSensor.h index 4847dfa174a9..a6adf2c129a1 100644 --- a/source/gameengine/Ketsji/KX_NearSensor.h +++ b/source/gameengine/Ketsji/KX_NearSensor.h @@ -53,7 +53,7 @@ class KX_NearSensor : public KX_CollisionSensor float margin, float resetmargin, bool bFindMaterial, - const STR_String& touchedpropname, + const std::string& touchedpropname, PHY_IPhysicsController* ctrl); #if 0 public: @@ -62,7 +62,7 @@ class KX_NearSensor : public KX_CollisionSensor double margin, double resetmargin, bool bFindMaterial, - const STR_String& touchedpropname, + const std::string& touchedpropname, class KX_Scene* scene); #endif virtual ~KX_NearSensor(); diff --git a/source/gameengine/Ketsji/KX_ObjectActuator.cpp b/source/gameengine/Ketsji/KX_ObjectActuator.cpp index 92dd872c3e91..369cc3bcddfd 100644 --- a/source/gameengine/Ketsji/KX_ObjectActuator.cpp +++ b/source/gameengine/Ketsji/KX_ObjectActuator.cpp @@ -436,7 +436,7 @@ PyAttributeDef KX_ObjectActuator::Attributes[] = { KX_PYATTRIBUTE_RW_FUNCTION("forceLimitZ", KX_ObjectActuator, pyattr_get_forceLimitZ, pyattr_set_forceLimitZ), KX_PYATTRIBUTE_VECTOR_RW_CHECK("pid", -100, 200, true, KX_ObjectActuator, m_pid, PyCheckPid), KX_PYATTRIBUTE_RW_FUNCTION("reference", KX_ObjectActuator,pyattr_get_reference,pyattr_set_reference), - { NULL } //Sentinel + KX_PYATTRIBUTE_NULL //Sentinel }; /* Attribute get/set functions */ diff --git a/source/gameengine/Ketsji/KX_ParentActuator.cpp b/source/gameengine/Ketsji/KX_ParentActuator.cpp index 949b9cccc27f..d389fb55f102 100644 --- a/source/gameengine/Ketsji/KX_ParentActuator.cpp +++ b/source/gameengine/Ketsji/KX_ParentActuator.cpp @@ -168,7 +168,7 @@ PyAttributeDef KX_ParentActuator::Attributes[] = { KX_PYATTRIBUTE_INT_RW("mode", KX_PARENT_NODEF+1, KX_PARENT_MAX-1, true, KX_ParentActuator, m_mode), KX_PYATTRIBUTE_BOOL_RW("compound", KX_ParentActuator, m_addToCompound), KX_PYATTRIBUTE_BOOL_RW("ghost", KX_ParentActuator, m_ghost), - { NULL } //Sentinel + KX_PYATTRIBUTE_NULL //Sentinel }; PyObject *KX_ParentActuator::pyattr_get_object(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef) diff --git a/source/gameengine/Ketsji/KX_PolyProxy.cpp b/source/gameengine/Ketsji/KX_PolyProxy.cpp index 6c63fb3db29a..76be7c6dd7a8 100644 --- a/source/gameengine/Ketsji/KX_PolyProxy.cpp +++ b/source/gameengine/Ketsji/KX_PolyProxy.cpp @@ -100,7 +100,7 @@ PyAttributeDef KX_PolyProxy::Attributes[] = { KX_PYATTRIBUTE_RO_FUNCTION("visible", KX_PolyProxy, pyattr_get_visible), KX_PYATTRIBUTE_RO_FUNCTION("collide", KX_PolyProxy, pyattr_get_collide), KX_PYATTRIBUTE_RO_FUNCTION("vertices", KX_PolyProxy, pyattr_get_vertices), - { NULL } //Sentinel + KX_PYATTRIBUTE_NULL //Sentinel }; KX_PolyProxy::KX_PolyProxy(KX_MeshProxy *meshProxy, RAS_MeshObject *mesh, RAS_Polygon* polygon) @@ -118,7 +118,7 @@ KX_PolyProxy::~KX_PolyProxy() // stuff for cvalue related things -STR_String KX_PolyProxy::GetName() +std::string KX_PolyProxy::GetName() { return "polygone"; } @@ -256,13 +256,13 @@ KX_PYMETHODDEF_DOC_NOARGS(KX_PolyProxy, isCollider, KX_PYMETHODDEF_DOC_NOARGS(KX_PolyProxy, getMaterialName, "getMaterialName() : returns the polygon material name, \"NoMaterial\" if no material\n") { - return PyUnicode_From_STR_String(m_polygon->GetMaterial()->GetPolyMaterial()->GetName()); + return PyUnicode_FromStdString(m_polygon->GetMaterial()->GetPolyMaterial()->GetName()); } KX_PYMETHODDEF_DOC_NOARGS(KX_PolyProxy, getTextureName, "getTexturelName() : returns the polygon texture name, \"NULL\" if no texture\n") { - return PyUnicode_From_STR_String(m_polygon->GetMaterial()->GetPolyMaterial()->GetTextureName()); + return PyUnicode_FromStdString(m_polygon->GetMaterial()->GetPolyMaterial()->GetTextureName()); } KX_PYMETHODDEF_DOC(KX_PolyProxy, getVertexIndex, diff --git a/source/gameengine/Ketsji/KX_PolyProxy.h b/source/gameengine/Ketsji/KX_PolyProxy.h index f2ec08a603c2..7d36faf4cdf4 100644 --- a/source/gameengine/Ketsji/KX_PolyProxy.h +++ b/source/gameengine/Ketsji/KX_PolyProxy.h @@ -52,7 +52,7 @@ class KX_PolyProxy : public CValue virtual ~KX_PolyProxy(); // stuff for cvalue related things - virtual STR_String GetName(); + virtual std::string GetName(); RAS_Polygon *GetPolygon(); KX_MeshProxy *GetMeshProxy(); diff --git a/source/gameengine/Ketsji/KX_PythonComponent.cpp b/source/gameengine/Ketsji/KX_PythonComponent.cpp index d40dcb1b617d..dd1730cb0b6f 100644 --- a/source/gameengine/Ketsji/KX_PythonComponent.cpp +++ b/source/gameengine/Ketsji/KX_PythonComponent.cpp @@ -31,7 +31,7 @@ #include "BKE_python_component.h" -KX_PythonComponent::KX_PythonComponent(const STR_String& name) +KX_PythonComponent::KX_PythonComponent(const std::string& name) :m_pc(NULL), m_gameobj(NULL), m_name(name), @@ -43,7 +43,7 @@ KX_PythonComponent::~KX_PythonComponent() { } -STR_String KX_PythonComponent::GetName() +std::string KX_PythonComponent::GetName() { return m_name; } @@ -115,7 +115,7 @@ void KX_PythonComponent::Update() PyObject *KX_PythonComponent::py_component_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { - KX_PythonComponent *comp = new KX_PythonComponent(STR_String(type->tp_name)); + KX_PythonComponent *comp = new KX_PythonComponent(type->tp_name); PyObject *proxy = py_base_new(type, PyTuple_Pack(1, comp->GetProxy()), kwds); if (!proxy) { @@ -154,7 +154,7 @@ PyMethodDef KX_PythonComponent::Methods[] = { PyAttributeDef KX_PythonComponent::Attributes[] = { KX_PYATTRIBUTE_RO_FUNCTION("object", KX_PythonComponent, pyattr_get_object), - {NULL} // Sentinel + KX_PYATTRIBUTE_NULL // Sentinel }; PyObject* KX_PythonComponent::pyattr_get_object(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) diff --git a/source/gameengine/Ketsji/KX_PythonComponent.h b/source/gameengine/Ketsji/KX_PythonComponent.h index 8d00de5aafe5..3b3d55e5474e 100644 --- a/source/gameengine/Ketsji/KX_PythonComponent.h +++ b/source/gameengine/Ketsji/KX_PythonComponent.h @@ -37,15 +37,15 @@ class KX_PythonComponent : public CValue private: PythonComponent *m_pc; KX_GameObject *m_gameobj; - STR_String m_name; + std::string m_name; bool m_init; public: - KX_PythonComponent(const STR_String& name); + KX_PythonComponent(const std::string& name); virtual ~KX_PythonComponent(); // stuff for cvalue related things - virtual STR_String GetName(); + virtual std::string GetName(); virtual CValue *GetReplica(); void ProcessReplica(); diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index 33a854597b88..1fb87e3ac7af 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -231,7 +231,7 @@ static PyObject *gPyExpandPath(PyObject *, PyObject *args) return NULL; BLI_strncpy(expanded, filename, FILE_MAX); - BLI_path_abs(expanded, KX_GetMainPath().ReadPtr()); + BLI_path_abs(expanded, KX_GetMainPath().c_str()); return PyC_UnicodeFromByte(expanded); } @@ -528,10 +528,10 @@ static PyObject *gPyGetBlendFileList(PyObject *, PyObject *args) if (searchpath) { BLI_strncpy(cpath, searchpath, FILE_MAX); - BLI_path_abs(cpath, KX_GetMainPath().ReadPtr()); + BLI_path_abs(cpath, KX_GetMainPath().c_str()); } else { /* Get the dir only */ - BLI_split_dir_part(KX_GetMainPath().ReadPtr(), cpath, sizeof(cpath)); + BLI_split_dir_part(KX_GetMainPath().c_str(), cpath, sizeof(cpath)); } if ((dp = opendir(cpath)) == NULL) { @@ -653,7 +653,7 @@ static PyObject *gLibLoad(PyObject *, PyObject *args, PyObject *kwds) char abs_path[FILE_MAX]; // Make the path absolute BLI_strncpy(abs_path, path, sizeof(abs_path)); - BLI_path_abs(abs_path, KX_GetMainPath().ReadPtr()); + BLI_path_abs(abs_path, KX_GetMainPath().c_str()); if ((status=kx_scene->GetSceneConverter()->LinkBlendFilePath(abs_path, group, kx_scene, &err_str, options))) { return status->GetProxy(); @@ -1033,22 +1033,29 @@ static PyObject *gPyDisableMotionBlur(PyObject *) Py_RETURN_NONE; } -static int getGLSLSettingFlag(const char *setting) +static int getGLSLSettingFlag(const std::string& setting) { - if (strcmp(setting, "lights") == 0) + if (setting == "lights") { return GAME_GLSL_NO_LIGHTS; - else if (strcmp(setting, "shaders") == 0) + } + else if (setting == "shaders") { return GAME_GLSL_NO_SHADERS; - else if (strcmp(setting, "shadows") == 0) + } + else if (setting == "shadows") { return GAME_GLSL_NO_SHADOWS; - else if (strcmp(setting, "ramps") == 0) + } + else if (setting == "ramps") { return GAME_GLSL_NO_RAMPS; - else if (strcmp(setting, "nodes") == 0) + } + else if (setting == "nodes") { return GAME_GLSL_NO_NODES; - else if (strcmp(setting, "extra_textures") == 0) + } + else if (setting == "extra_textures") { return GAME_GLSL_NO_EXTRA_TEX; - else + } + else { return -1; + } } static PyObject *gPySetGLSLMaterialSetting(PyObject *, @@ -1861,8 +1868,8 @@ static void initPySysObjects__append(PyObject *sys_path, const char *filename) char expanded[FILE_MAX]; BLI_split_dir_part(filename, expanded, sizeof(expanded)); /* get the dir part of filename only */ - BLI_path_abs(expanded, KX_GetMainPath().ReadPtr()); /* filename from lib->filename is (always?) absolute, so this may not be needed but it wont hurt */ - BLI_cleanup_file(KX_GetMainPath().ReadPtr(), expanded); /* Don't use BLI_cleanup_dir because it adds a slash - BREAKS WIN32 ONLY */ + BLI_path_abs(expanded, KX_GetMainPath().c_str()); /* filename from lib->filename is (always?) absolute, so this may not be needed but it wont hurt */ + BLI_cleanup_file(KX_GetMainPath().c_str(), expanded); /* Don't use BLI_cleanup_dir because it adds a slash - BREAKS WIN32 ONLY */ item = PyC_UnicodeFromByte(expanded); if (PySequence_Index(sys_path, item) == -1) { @@ -1896,7 +1903,7 @@ static void initPySysObjects(Main *maggie) lib= (Library *)lib->id.next; } - initPySysObjects__append(sys_path, KX_GetMainPath().ReadPtr()); + initPySysObjects__append(sys_path, KX_GetMainPath().c_str()); } static void restorePySysObjects(void) @@ -2648,10 +2655,10 @@ void saveGamePythonConfig() CM_Error("bge.logic failed to import bge.logic.globalDict will be lost"); } - STR_String marshal_path = pathGamePythonConfig(); + std::string marshal_path = pathGamePythonConfig(); if (marshal_length && marshal_buffer) { - FILE *fp = fopen(marshal_path.ReadPtr(), "wb"); + FILE *fp = fopen(marshal_path.c_str(), "wb"); if (fp) { if (fwrite(marshal_buffer, 1, marshal_length, fp) != marshal_length) { @@ -2675,9 +2682,9 @@ void saveGamePythonConfig() void loadGamePythonConfig() { - STR_String marshal_path = pathGamePythonConfig(); + std::string marshal_path = pathGamePythonConfig(); - FILE *fp = fopen(marshal_path.ReadPtr(), "rb"); + FILE *fp = fopen(marshal_path.c_str(), "rb"); if (fp) { // obtain file size: @@ -2725,28 +2732,28 @@ void loadGamePythonConfig() } } else { - CM_Error("could not read all of '" << marshal_path.ReadPtr() << "'"); + CM_Error("could not read all of '" << marshal_path << "'"); } free(marshal_buffer); fclose(fp); } else { - CM_Error("could not open '" << marshal_path.ReadPtr() << "'"); + CM_Error("could not open '" << marshal_path << "'"); } } -STR_String pathGamePythonConfig() +std::string pathGamePythonConfig() { - STR_String path = KX_GetOrigPath(); - int len = path.Length(); + std::string path = KX_GetOrigPath(); + int len = path.size(); /* replace extension */ - if (BLI_testextensie(path.Ptr(), ".blend")) { - path = path.Left(len - 6) + STR_String(".bgeconf"); + if (BLI_testextensie(path.c_str(), ".blend")) { + path = path.substr(0, len - 6) + std::string(".bgeconf"); } else { - path += STR_String(".bgeconf"); + path += std::string(".bgeconf"); } return path; diff --git a/source/gameengine/Ketsji/KX_PythonInit.h b/source/gameengine/Ketsji/KX_PythonInit.h index 9d42103accfb..4549a2e9ad72 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.h +++ b/source/gameengine/Ketsji/KX_PythonInit.h @@ -33,7 +33,7 @@ #define __KX_PYTHONINIT_H__ #include "EXP_Python.h" -#include "STR_String.h" +#include #include "MT_Vector3.h" #include "DEV_JoystickDefines.h" // For JOYINDEX_MAX @@ -54,7 +54,7 @@ void exitGamePlayerPythonScripting(); void exitGamePythonScripting(); void setupGamePython(KX_KetsjiEngine *ketsjiengine, Main *blenderdata, PyObject *pyGlobalDict, PyObject **gameLogic, int argc, char **argv); -STR_String pathGamePythonConfig(); +std::string pathGamePythonConfig(); void saveGamePythonConfig(); void loadGamePythonConfig(); diff --git a/source/gameengine/Ketsji/KX_PythonInitTypes.cpp b/source/gameengine/Ketsji/KX_PythonInitTypes.cpp index 06515fe24fae..9babf20f8d99 100644 --- a/source/gameengine/Ketsji/KX_PythonInitTypes.cpp +++ b/source/gameengine/Ketsji/KX_PythonInitTypes.cpp @@ -116,7 +116,7 @@ static void PyType_Attr_Set(PyGetSetDef *attr_getset, PyAttributeDef *attr) { - attr_getset->name= (char *)attr->m_name; + attr_getset->name = (char *)attr->m_name.c_str(); attr_getset->doc= NULL; attr_getset->get= reinterpret_cast(PyObjectPlus::py_get_attrdef); @@ -137,28 +137,28 @@ static void PyType_Ready_ADD(PyObject *dict, PyTypeObject *tp, PyAttributeDef *a /* we need to do this for all types before calling PyType_Ready * since they will call the parents PyType_Ready and those might not have initialized vars yet */ - if (tp->tp_getset==NULL && ((attributes && attributes->m_name) || (attributesPtr && attributesPtr->m_name))) { + if (tp->tp_getset==NULL && ((attributes && !attributes->m_name.empty()) || (attributesPtr && !attributesPtr->m_name.empty()))) { PyGetSetDef *attr_getset; int attr_tot= 0; if (attributes) { - for (attr= attributes; attr->m_name; attr++, attr_tot++) + for (attr = attributes; !attr->m_name.empty(); attr++, attr_tot++) attr->m_usePtr = false; } if (attributesPtr) { - for (attr= attributesPtr; attr->m_name; attr++, attr_tot++) + for (attr= attributesPtr; !attr->m_name.empty(); attr++, attr_tot++) attr->m_usePtr = true; } tp->tp_getset = attr_getset = reinterpret_cast(PyMem_Malloc((attr_tot+1) * sizeof(PyGetSetDef))); // XXX - Todo, free if (attributes) { - for (attr= attributes; attr->m_name; attr++, attr_getset++) { + for (attr= attributes; !attr->m_name.empty(); attr++, attr_getset++) { PyType_Attr_Set(attr_getset, attr); } } if (attributesPtr) { - for (attr= attributesPtr; attr->m_name; attr++, attr_getset++) { + for (attr= attributesPtr; !attr->m_name.empty(); attr++, attr_getset++) { PyType_Attr_Set(attr_getset, attr); } } diff --git a/source/gameengine/Ketsji/KX_RadarSensor.cpp b/source/gameengine/Ketsji/KX_RadarSensor.cpp index 4310038369ef..a5aaa4eab4dc 100644 --- a/source/gameengine/Ketsji/KX_RadarSensor.cpp +++ b/source/gameengine/Ketsji/KX_RadarSensor.cpp @@ -49,7 +49,7 @@ KX_RadarSensor::KX_RadarSensor(SCA_EventManager* eventmgr, double margin, double resetmargin, bool bFindMaterial, - const STR_String& touchedpropname) + const std::string& touchedpropname) : KX_NearSensor( eventmgr, @@ -205,7 +205,7 @@ PyTypeObject KX_RadarSensor::Type = { }; PyMethodDef KX_RadarSensor::Methods[] = { - {NULL} //Sentinel + {NULL, NULL} //Sentinel }; PyAttributeDef KX_RadarSensor::Attributes[] = { @@ -214,7 +214,7 @@ PyAttributeDef KX_RadarSensor::Attributes[] = { KX_PYATTRIBUTE_FLOAT_RO("distance", KX_RadarSensor, m_coneheight), KX_PYATTRIBUTE_RO_FUNCTION("angle", KX_RadarSensor, pyattr_get_angle), KX_PYATTRIBUTE_INT_RW("axis", 0, 5, true, KX_RadarSensor, m_axis), - {NULL} //Sentinel + KX_PYATTRIBUTE_NULL //Sentinel }; PyObject *KX_RadarSensor::pyattr_get_angle(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) diff --git a/source/gameengine/Ketsji/KX_RadarSensor.h b/source/gameengine/Ketsji/KX_RadarSensor.h index 1b2742eb5ed2..5fc8107a4199 100644 --- a/source/gameengine/Ketsji/KX_RadarSensor.h +++ b/source/gameengine/Ketsji/KX_RadarSensor.h @@ -72,7 +72,7 @@ class KX_RadarSensor : public KX_NearSensor double margin, double resetmargin, bool bFindMaterial, - const STR_String& touchedpropname); + const std::string& touchedpropname); KX_RadarSensor(); virtual ~KX_RadarSensor(); virtual void SynchronizeTransform(); diff --git a/source/gameengine/Ketsji/KX_RaySensor.cpp b/source/gameengine/Ketsji/KX_RaySensor.cpp index e66c8c6da18f..8010e63d838d 100644 --- a/source/gameengine/Ketsji/KX_RaySensor.cpp +++ b/source/gameengine/Ketsji/KX_RaySensor.cpp @@ -51,7 +51,7 @@ KX_RaySensor::KX_RaySensor(class SCA_EventManager* eventmgr, SCA_IObject* gameobj, - const STR_String& propname, + const std::string& propname, bool bFindMaterial, bool bXRay, double distance, @@ -114,7 +114,7 @@ bool KX_RaySensor::RayHit(KX_ClientObjectInfo *client, KX_RayCast *result, void bool bFound = false; bool hitMaterial = false; - if (m_propertyname.Length() == 0) + if (m_propertyname.size() == 0) { bFound = true; } @@ -124,7 +124,7 @@ bool KX_RaySensor::RayHit(KX_ClientObjectInfo *client, KX_RayCast *result, void for (unsigned int i = 0; i < hitKXObj->GetMeshCount(); ++i) { RAS_MeshObject *meshObj = hitKXObj->GetMesh(i); for (unsigned int j = 0; j < meshObj->NumMaterials(); ++j) { - bFound = strcmp(m_propertyname.ReadPtr(), meshObj->GetMaterialName(j).ReadPtr() + 2) == 0; + bFound = (m_propertyname == std::string(meshObj->GetMaterialName(j), 2)); if (bFound) { hitMaterial = true; break; @@ -175,14 +175,14 @@ bool KX_RaySensor::NeedRayCast(KX_ClientObjectInfo *client, void *UNUSED(data)) return false; } - if (m_bXRay && m_propertyname.Length() != 0) + if (m_bXRay && m_propertyname.size() != 0) { if (m_bFindMaterial) { bool found = false; for (unsigned int i = 0; i < hitKXObj->GetMeshCount(); ++i) { RAS_MeshObject *meshObj = hitKXObj->GetMesh(i); for (unsigned int j = 0; j < meshObj->NumMaterials(); ++j) { - found = strcmp(m_propertyname.ReadPtr(), meshObj->GetMaterialName(j).ReadPtr() + 2) == 0; + found = (m_propertyname == std::string(meshObj->GetMaterialName(j), 2)); if (found) break; } @@ -373,7 +373,7 @@ PyAttributeDef KX_RaySensor::Attributes[] = { KX_PYATTRIBUTE_FLOAT_ARRAY_RO("hitNormal", KX_RaySensor, m_hitNormal, 3), KX_PYATTRIBUTE_STRING_RO("hitMaterial", KX_RaySensor, m_hitMaterial), KX_PYATTRIBUTE_RO_FUNCTION("hitObject", KX_RaySensor, pyattr_get_hitobject), - { NULL } //Sentinel + KX_PYATTRIBUTE_NULL //Sentinel }; PyObject *KX_RaySensor::pyattr_get_hitobject(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) diff --git a/source/gameengine/Ketsji/KX_RaySensor.h b/source/gameengine/Ketsji/KX_RaySensor.h index 5b35e44e7fbd..19bbf45a3113 100644 --- a/source/gameengine/Ketsji/KX_RaySensor.h +++ b/source/gameengine/Ketsji/KX_RaySensor.h @@ -46,7 +46,7 @@ class KX_RayCast; class KX_RaySensor : public SCA_ISensor { Py_Header - STR_String m_propertyname; + std::string m_propertyname; bool m_bFindMaterial; bool m_bXRay; float m_distance; @@ -59,12 +59,12 @@ class KX_RaySensor : public SCA_ISensor SCA_IObject* m_hitObject; float m_hitNormal[3]; float m_rayDirection[3]; - STR_String m_hitMaterial; + std::string m_hitMaterial; public: KX_RaySensor(class SCA_EventManager* eventmgr, SCA_IObject* gameobj, - const STR_String& propname, + const std::string& propname, bool bFindMaterial, bool bXRay, double distance, diff --git a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp index 01d9d1ba6171..6ce46c914c79 100644 --- a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp +++ b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp @@ -199,7 +199,7 @@ PyAttributeDef KX_SCA_AddObjectActuator::Attributes[] = { KX_PYATTRIBUTE_FLOAT_RW("time", 0.0f, FLT_MAX, KX_SCA_AddObjectActuator, m_timeProp), KX_PYATTRIBUTE_FLOAT_ARRAY_RW("linearVelocity",-FLT_MAX,FLT_MAX,KX_SCA_AddObjectActuator,m_linear_velocity,3), KX_PYATTRIBUTE_FLOAT_ARRAY_RW("angularVelocity",-FLT_MAX,FLT_MAX,KX_SCA_AddObjectActuator,m_angular_velocity,3), - { NULL } //Sentinel + KX_PYATTRIBUTE_NULL //Sentinel }; PyObject *KX_SCA_AddObjectActuator::pyattr_get_object(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef) diff --git a/source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp b/source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp index 15d89927fc74..2fb9605193bb 100644 --- a/source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp +++ b/source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp @@ -74,7 +74,7 @@ PyMethodDef KX_SCA_DynamicActuator::Methods[] = { PyAttributeDef KX_SCA_DynamicActuator::Attributes[] = { KX_PYATTRIBUTE_SHORT_RW("mode",0,4,false,KX_SCA_DynamicActuator,m_dyn_operation), KX_PYATTRIBUTE_FLOAT_RW("mass",0.0f,FLT_MAX,KX_SCA_DynamicActuator,m_setmass), - { NULL } //Sentinel + KX_PYATTRIBUTE_NULL //Sentinel }; #endif // WITH_PYTHON diff --git a/source/gameengine/Ketsji/KX_SCA_EndObjectActuator.cpp b/source/gameengine/Ketsji/KX_SCA_EndObjectActuator.cpp index 81c9dc916035..9f8ffdd66ede 100644 --- a/source/gameengine/Ketsji/KX_SCA_EndObjectActuator.cpp +++ b/source/gameengine/Ketsji/KX_SCA_EndObjectActuator.cpp @@ -117,7 +117,7 @@ PyMethodDef KX_SCA_EndObjectActuator::Methods[] = { }; PyAttributeDef KX_SCA_EndObjectActuator::Attributes[] = { - { NULL } //Sentinel + KX_PYATTRIBUTE_NULL //Sentinel }; #endif // WITH_PYTHON diff --git a/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp b/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp index 1bf76de0b403..77024f44e242 100644 --- a/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp +++ b/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp @@ -84,7 +84,7 @@ PyAttributeDef KX_SCA_ReplaceMeshActuator::Attributes[] = { KX_PYATTRIBUTE_RW_FUNCTION("mesh", KX_SCA_ReplaceMeshActuator, pyattr_get_mesh, pyattr_set_mesh), KX_PYATTRIBUTE_BOOL_RW ("useDisplayMesh", KX_SCA_ReplaceMeshActuator, m_use_gfx), KX_PYATTRIBUTE_BOOL_RW ("usePhysicsMesh", KX_SCA_ReplaceMeshActuator, m_use_phys), - { NULL } //Sentinel + KX_PYATTRIBUTE_NULL //Sentinel }; PyObject *KX_SCA_ReplaceMeshActuator::pyattr_get_mesh(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef) diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index 64b23c879f08..ce9405f91800 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -141,7 +141,7 @@ SG_Callbacks KX_Scene::m_callbacks = SG_Callbacks( KX_Scene::KX_ScenegraphRescheduleFunc); KX_Scene::KX_Scene(SCA_IInputDevice *inputDevice, - const STR_String& sceneName, + const std::string& sceneName, Scene *scene, class RAS_ICanvas* canvas, KX_NetworkMessageManager *messageManager): @@ -311,13 +311,13 @@ KX_Scene::~KX_Scene() #endif } -STR_String KX_Scene::GetName() +std::string KX_Scene::GetName() { return m_sceneName; } /// Set the name of the value -void KX_Scene::SetName(const char *name) +void KX_Scene::SetName(const std::string& name) { m_sceneName = name; } @@ -450,12 +450,12 @@ void KX_Scene::AddObjectDebugProperties(class KX_GameObject* gameobj) while (prop) { if (prop->flag & PROP_DEBUG) - AddDebugProperty(gameobj,STR_String(prop->name)); + AddDebugProperty(gameobj, prop->name); prop = prop->next; } if (blenderobject->scaflag & OB_DEBUGSTATE) - AddDebugProperty(gameobj,STR_String("__state__")); + AddDebugProperty(gameobj, "__state__"); } void KX_Scene::RemoveNodeDestructObject(class SG_IObject* node,class CValue* gameobj) @@ -2267,7 +2267,7 @@ PySequenceMethods KX_Scene::Sequence = { PyObject *KX_Scene::pyattr_get_name(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { KX_Scene* self = static_cast(self_v); - return PyUnicode_From_STR_String(self->GetName()); + return PyUnicode_FromStdString(self->GetName()); } PyObject *KX_Scene::pyattr_get_objects(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) @@ -2344,7 +2344,7 @@ int KX_Scene::pyattr_set_active_camera(void *self_v, const KX_PYATTRIBUTE_DEF *a return PY_SET_ATTR_SUCCESS; } -static std::map callbacksTable = { +static std::map callbacksTable = { {"pre_draw", KX_Scene::PRE_DRAW}, {"pre_draw_setup", KX_Scene::PRE_DRAW_SETUP}, {"post_draw", KX_Scene::POST_DRAW} @@ -2420,7 +2420,7 @@ PyAttributeDef KX_Scene::Attributes[] = { KX_PYATTRIBUTE_BOOL_RO("activity_culling", KX_Scene, m_activity_culling), KX_PYATTRIBUTE_FLOAT_RW("activity_culling_radius", 0.5f, FLT_MAX, KX_Scene, m_activity_box_radius), KX_PYATTRIBUTE_BOOL_RO("dbvt_culling", KX_Scene, m_dbvt_culling), - { NULL } //Sentinel + KX_PYATTRIBUTE_NULL //Sentinel }; KX_PYMETHODDEF_DOC(KX_Scene, addObject, diff --git a/source/gameengine/Ketsji/KX_Scene.h b/source/gameengine/Ketsji/KX_Scene.h index d373f11ec90a..b5ce51a264da 100644 --- a/source/gameengine/Ketsji/KX_Scene.h +++ b/source/gameengine/Ketsji/KX_Scene.h @@ -179,7 +179,7 @@ class KX_Scene : public CValue, public SCA_IScene /** * The name of the scene */ - STR_String m_sceneName; + std::string m_sceneName; /** * stores the world-settings for a scene @@ -306,7 +306,7 @@ class KX_Scene : public CValue, public SCA_IScene public: KX_Scene(SCA_IInputDevice *inputDevice, - const STR_String& scenename, + const std::string& scenename, struct Scene* scene, class RAS_ICanvas* canvas, KX_NetworkMessageManager *messageManager); @@ -549,10 +549,10 @@ class KX_Scene : public CValue, public SCA_IScene KX_ObstacleSimulation* GetObstacleSimulation() { return m_obstacleSimulation; } /** Inherited from CValue -- returns the name of this object. */ - virtual STR_String GetName(); + virtual std::string GetName(); /** Inherited from CValue -- set the name of this object. */ - virtual void SetName(const char *name); + virtual void SetName(const std::string& name); #ifdef WITH_PYTHON /* --------------------------------------------------------------------- */ @@ -585,7 +585,7 @@ class KX_Scene : public CValue, public SCA_IScene static PyObject* pyattr_get_gravity(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef); static int pyattr_set_gravity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); - virtual PyObject *py_repr(void) { return PyUnicode_From_STR_String(GetName()); } + virtual PyObject *py_repr(void) { return PyUnicode_FromStdString(GetName()); } /* getitem/setitem */ static PyMappingMethods Mapping; diff --git a/source/gameengine/Ketsji/KX_SceneActuator.cpp b/source/gameengine/Ketsji/KX_SceneActuator.cpp index 77e8fe2581cf..c3f624972faf 100644 --- a/source/gameengine/Ketsji/KX_SceneActuator.cpp +++ b/source/gameengine/Ketsji/KX_SceneActuator.cpp @@ -49,7 +49,7 @@ KX_SceneActuator::KX_SceneActuator(SCA_IObject *gameobj, int mode, KX_Scene *scene, KX_KetsjiEngine* ketsjiEngine, - const STR_String& nextSceneName, + const std::string& nextSceneName, KX_Camera* camera) : SCA_IActuator(gameobj, KX_ACT_SCENE) { @@ -144,7 +144,7 @@ bool KX_SceneActuator::Update() break; } - if (!m_nextSceneName.Length()) + if (!m_nextSceneName.size()) return false; switch (m_mode) @@ -228,7 +228,7 @@ PyAttributeDef KX_SceneActuator::Attributes[] = { KX_PYATTRIBUTE_RW_FUNCTION("camera",KX_SceneActuator,pyattr_get_camera,pyattr_set_camera), KX_PYATTRIBUTE_BOOL_RW("useRestart", KX_SceneActuator, m_restart), KX_PYATTRIBUTE_INT_RW("mode", KX_SCENE_NODEF+1, KX_SCENE_MAX-1, true, KX_SceneActuator, m_mode), - { NULL } //Sentinel + KX_PYATTRIBUTE_NULL //Sentinel }; PyObject *KX_SceneActuator::pyattr_get_camera(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef) diff --git a/source/gameengine/Ketsji/KX_SceneActuator.h b/source/gameengine/Ketsji/KX_SceneActuator.h index e7068886e4be..aa8d044e1308 100644 --- a/source/gameengine/Ketsji/KX_SceneActuator.h +++ b/source/gameengine/Ketsji/KX_SceneActuator.h @@ -48,7 +48,7 @@ class KX_SceneActuator : public SCA_IActuator class KX_Scene* m_scene; class KX_KetsjiEngine* m_KetsjiEngine; /** The scene to switch to. */ - STR_String m_nextSceneName; + std::string m_nextSceneName; // (Set Camera) Object class KX_Camera* m_camera; @@ -72,7 +72,7 @@ class KX_SceneActuator : public SCA_IActuator int mode, KX_Scene* scene, KX_KetsjiEngine* ketsjiEngine, - const STR_String& nextSceneName, + const std::string& nextSceneName, KX_Camera* camera); virtual ~KX_SceneActuator(); diff --git a/source/gameengine/Ketsji/KX_SoundActuator.cpp b/source/gameengine/Ketsji/KX_SoundActuator.cpp index bdfbd5a08c96..800c27d10e38 100644 --- a/source/gameengine/Ketsji/KX_SoundActuator.cpp +++ b/source/gameengine/Ketsji/KX_SoundActuator.cpp @@ -343,7 +343,7 @@ PyAttributeDef KX_SoundActuator::Attributes[] = { KX_PYATTRIBUTE_RW_FUNCTION("volume", KX_SoundActuator, pyattr_get_gain, pyattr_set_gain), KX_PYATTRIBUTE_RW_FUNCTION("pitch", KX_SoundActuator, pyattr_get_pitch, pyattr_set_pitch), KX_PYATTRIBUTE_ENUM_RW("mode",KX_SoundActuator::KX_SOUNDACT_NODEF+1,KX_SoundActuator::KX_SOUNDACT_MAX-1,false,KX_SoundActuator,m_type), - { NULL } //Sentinel + KX_PYATTRIBUTE_NULL //Sentinel }; /* Methods ----------------------------------------------------------------- */ @@ -397,34 +397,34 @@ KX_PYMETHODDEF_DOC_NOARGS(KX_SoundActuator, stopSound, PyObject *KX_SoundActuator::pyattr_get_3d_property(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef) { KX_SoundActuator * actuator = static_cast (self); - const char* prop = attrdef->m_name; + const std::string& prop = attrdef->m_name; float result_value = 0.0f; - if (!strcmp(prop, "volume_maximum")) { + if (prop == "volume_maximum") { result_value = actuator->m_3d.max_gain; - - } else if (!strcmp(prop, "volume_minimum")) { + } + else if (prop == "volume_minimum") { result_value = actuator->m_3d.min_gain; - - } else if (!strcmp(prop, "distance_reference")) { + } + else if (prop == "distance_reference") { result_value = actuator->m_3d.reference_distance; - - } else if (!strcmp(prop, "distance_maximum")) { + } + else if (prop == "distance_maximum") { result_value = actuator->m_3d.max_distance; - - } else if (!strcmp(prop, "attenuation")) { + } + else if (prop == "attenuation") { result_value = actuator->m_3d.rolloff_factor; - - } else if (!strcmp(prop, "cone_angle_inner")) { + } + else if (prop == "cone_angle_inner") { result_value = actuator->m_3d.cone_inner_angle; - - } else if (!strcmp(prop, "cone_angle_outer")) { + } + else if (prop == "cone_angle_outer") { result_value = actuator->m_3d.cone_outer_angle; - - } else if (!strcmp(prop, "cone_volume_outer")) { + } + else if (prop == "cone_volume_outer") { result_value = actuator->m_3d.cone_outer_gain; - - } else { + } + else { Py_RETURN_NONE; } @@ -484,7 +484,7 @@ PyObject *KX_SoundActuator::pyattr_get_sound(void *self, const struct KX_PYATTRI int KX_SoundActuator::pyattr_set_3d_property(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) { KX_SoundActuator * actuator = static_cast (self); - const char* prop = attrdef->m_name; + const std::string& prop = attrdef->m_name; float prop_value = 0.0f; if (!PyArg_Parse(value, "f", &prop_value)) @@ -494,56 +494,56 @@ int KX_SoundActuator::pyattr_set_3d_property(void *self, const struct KX_PYATTRI if (!actuator->m_is3d) return PY_SET_ATTR_FAIL; - if (!strcmp(prop, "volume_maximum")) { + if (prop == "volume_maximum") { actuator->m_3d.max_gain = prop_value; #ifdef WITH_AUDASPACE if (actuator->m_handle) AUD_Handle_setVolumeMaximum(actuator->m_handle, prop_value); #endif // WITH_AUDASPACE - } else if (!strcmp(prop, "volume_minimum")) { + } else if (prop == "volume_minimum") { actuator->m_3d.min_gain = prop_value; #ifdef WITH_AUDASPACE if (actuator->m_handle) AUD_Handle_setVolumeMinimum(actuator->m_handle, prop_value); #endif // WITH_AUDASPACE - } else if (!strcmp(prop, "distance_reference")) { + } else if (prop == "distance_reference") { actuator->m_3d.reference_distance = prop_value; #ifdef WITH_AUDASPACE if (actuator->m_handle) AUD_Handle_setDistanceReference(actuator->m_handle, prop_value); #endif // WITH_AUDASPACE - } else if (!strcmp(prop, "distance_maximum")) { + } else if (prop == "distance_maximum") { actuator->m_3d.max_distance = prop_value; #ifdef WITH_AUDASPACE if (actuator->m_handle) AUD_Handle_setDistanceMaximum(actuator->m_handle, prop_value); #endif // WITH_AUDASPACE - } else if (!strcmp(prop, "attenuation")) { + } else if (prop == "attenuation") { actuator->m_3d.rolloff_factor = prop_value; #ifdef WITH_AUDASPACE if (actuator->m_handle) AUD_Handle_setAttenuation(actuator->m_handle, prop_value); #endif // WITH_AUDASPACE - } else if (!!strcmp(prop, "cone_angle_inner")) { + } else if (prop == "cone_angle_inner") { actuator->m_3d.cone_inner_angle = prop_value; #ifdef WITH_AUDASPACE if (actuator->m_handle) AUD_Handle_setConeAngleInner(actuator->m_handle, prop_value); #endif // WITH_AUDASPACE - } else if (!strcmp(prop, "cone_angle_outer")) { + } else if (prop == "cone_angle_outer") { actuator->m_3d.cone_outer_angle = prop_value; #ifdef WITH_AUDASPACE if (actuator->m_handle) AUD_Handle_setConeAngleOuter(actuator->m_handle, prop_value); #endif // WITH_AUDASPACE - } else if (!strcmp(prop, "cone_volume_outer")) { + } else if (prop == "cone_volume_outer") { actuator->m_3d.cone_outer_gain = prop_value; #ifdef WITH_AUDASPACE if (actuator->m_handle) diff --git a/source/gameengine/Ketsji/KX_StateActuator.cpp b/source/gameengine/Ketsji/KX_StateActuator.cpp index d918f87c4bf0..bbc4f695637e 100644 --- a/source/gameengine/Ketsji/KX_StateActuator.cpp +++ b/source/gameengine/Ketsji/KX_StateActuator.cpp @@ -165,7 +165,7 @@ PyMethodDef KX_StateActuator::Methods[] = { PyAttributeDef KX_StateActuator::Attributes[] = { KX_PYATTRIBUTE_INT_RW("operation",KX_StateActuator::OP_NOP+1,KX_StateActuator::OP_COUNT-1,false,KX_StateActuator,m_operation), KX_PYATTRIBUTE_INT_RW("mask",0,0x3FFFFFFF,false,KX_StateActuator,m_mask), - { NULL } //Sentinel + KX_PYATTRIBUTE_NULL //Sentinel }; #endif // WITH_PYTHON diff --git a/source/gameengine/Ketsji/KX_SteeringActuator.cpp b/source/gameengine/Ketsji/KX_SteeringActuator.cpp index 83512a2296e6..53da6b4ca975 100644 --- a/source/gameengine/Ketsji/KX_SteeringActuator.cpp +++ b/source/gameengine/Ketsji/KX_SteeringActuator.cpp @@ -565,7 +565,7 @@ PyAttributeDef KX_SteeringActuator::Attributes[] = { KX_PYATTRIBUTE_INT_RW("pathUpdatePeriod", -1, 100000, true, KX_SteeringActuator, m_pathUpdatePeriod), KX_PYATTRIBUTE_BOOL_RW("lockZVelocity", KX_SteeringActuator, m_lockzvel), KX_PYATTRIBUTE_RO_FUNCTION("path", KX_SteeringActuator, pyattr_get_path), - { NULL } //Sentinel + KX_PYATTRIBUTE_NULL //Sentinel }; PyObject *KX_SteeringActuator::pyattr_get_target(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef) diff --git a/source/gameengine/Ketsji/KX_TextMaterial.cpp b/source/gameengine/Ketsji/KX_TextMaterial.cpp index 5b45845e4943..3214ece4afec 100644 --- a/source/gameengine/Ketsji/KX_TextMaterial.cpp +++ b/source/gameengine/Ketsji/KX_TextMaterial.cpp @@ -67,7 +67,7 @@ void KX_TextMaterial::ActivateMeshSlot(RAS_MeshSlot *ms, RAS_IRasterizer *rasty) { } -const STR_String KX_TextMaterial::GetTextureName() const +const std::string KX_TextMaterial::GetTextureName() const { return ""; } diff --git a/source/gameengine/Ketsji/KX_TextMaterial.h b/source/gameengine/Ketsji/KX_TextMaterial.h index f7955d5766d3..c459254c4cad 100644 --- a/source/gameengine/Ketsji/KX_TextMaterial.h +++ b/source/gameengine/Ketsji/KX_TextMaterial.h @@ -42,7 +42,7 @@ class KX_TextMaterial : public RAS_IPolyMaterial virtual void DesactivateInstancing(); virtual void ActivateMeshSlot(RAS_MeshSlot *ms, RAS_IRasterizer *rasty); - virtual const STR_String GetTextureName() const; + virtual const std::string GetTextureName() const; virtual Material *GetBlenderMaterial() const; virtual Image *GetBlenderImage() const; virtual MTexPoly *GetMTexPoly() const; diff --git a/source/gameengine/Ketsji/KX_TrackToActuator.cpp b/source/gameengine/Ketsji/KX_TrackToActuator.cpp index 3046f3dde88b..cf357b0723b4 100644 --- a/source/gameengine/Ketsji/KX_TrackToActuator.cpp +++ b/source/gameengine/Ketsji/KX_TrackToActuator.cpp @@ -394,7 +394,7 @@ PyAttributeDef KX_TrackToActuator::Attributes[] = { KX_PYATTRIBUTE_INT_RW("trackAxis", 0, 5, true, KX_TrackToActuator,m_trackflag), KX_PYATTRIBUTE_RW_FUNCTION("object", KX_TrackToActuator, pyattr_get_object, pyattr_set_object), - { NULL } //Sentinel + KX_PYATTRIBUTE_NULL //Sentinel }; PyObject *KX_TrackToActuator::pyattr_get_object(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef) diff --git a/source/gameengine/Ketsji/KX_VehicleWrapper.cpp b/source/gameengine/Ketsji/KX_VehicleWrapper.cpp index 278fd85d6eed..dc9b367152b2 100644 --- a/source/gameengine/Ketsji/KX_VehicleWrapper.cpp +++ b/source/gameengine/Ketsji/KX_VehicleWrapper.cpp @@ -53,7 +53,7 @@ KX_VehicleWrapper::~KX_VehicleWrapper() m_motionStates.clear(); } -STR_String KX_VehicleWrapper::GetName() +std::string KX_VehicleWrapper::GetName() { return "KX_VehicleWrapper"; } @@ -381,7 +381,7 @@ PyMethodDef KX_VehicleWrapper::Methods[] = { PyAttributeDef KX_VehicleWrapper::Attributes[] = { KX_PYATTRIBUTE_RW_FUNCTION("rayMask", KX_VehicleWrapper, pyattr_get_ray_mask, pyattr_set_ray_mask), - { NULL } //Sentinel + KX_PYATTRIBUTE_NULL //Sentinel }; PyObject *KX_VehicleWrapper::pyattr_get_ray_mask(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef) diff --git a/source/gameengine/Ketsji/KX_VehicleWrapper.h b/source/gameengine/Ketsji/KX_VehicleWrapper.h index a9e447e229be..8f537e74ba22 100644 --- a/source/gameengine/Ketsji/KX_VehicleWrapper.h +++ b/source/gameengine/Ketsji/KX_VehicleWrapper.h @@ -23,7 +23,7 @@ class KX_VehicleWrapper : public CValue KX_VehicleWrapper(PHY_IVehicle* vehicle,class PHY_IPhysicsEnvironment* physenv); virtual ~KX_VehicleWrapper (); - virtual STR_String GetName(); + virtual std::string GetName(); int getConstraintId(); diff --git a/source/gameengine/Ketsji/KX_VertexProxy.cpp b/source/gameengine/Ketsji/KX_VertexProxy.cpp index bbc28eba8f91..f9b7a542b15c 100644 --- a/source/gameengine/Ketsji/KX_VertexProxy.cpp +++ b/source/gameengine/Ketsji/KX_VertexProxy.cpp @@ -40,6 +40,8 @@ #include "EXP_ListWrapper.h" +#include + PyTypeObject KX_VertexProxy::Type = { PyVarObject_HEAD_INIT(NULL, 0) "KX_VertexProxy", @@ -102,7 +104,7 @@ PyAttributeDef KX_VertexProxy::Attributes[] = { KX_PYATTRIBUTE_RW_FUNCTION("colors", KX_VertexProxy, pyattr_get_colors, pyattr_set_colors), KX_PYATTRIBUTE_RW_FUNCTION("normal", KX_VertexProxy, pyattr_get_normal, pyattr_set_normal), - {NULL} //Sentinel + KX_PYATTRIBUTE_NULL //Sentinel }; PyObject *KX_VertexProxy::pyattr_get_x(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) @@ -475,7 +477,7 @@ int KX_VertexProxy::pyattr_set_uvs(void *self_v, const struct KX_PYATTRIBUTE_DEF self->m_vertex->SetUV(i, vec); } else { - PyErr_SetString(PyExc_AttributeError, STR_String().Format("list[%d] was not a vector", i).ReadPtr()); + PyErr_SetString(PyExc_AttributeError, ((boost::format("list[%d] was not a vector") % i).str().c_str())); return PY_SET_ATTR_FAIL; } } @@ -510,7 +512,7 @@ int KX_VertexProxy::pyattr_set_colors(void *self_v, const struct KX_PYATTRIBUTE_ self->m_vertex->SetRGBA(i, vec); } else { - PyErr_SetString(PyExc_AttributeError, STR_String().Format("list[%d] was not a vector", i).ReadPtr()); + PyErr_SetString(PyExc_AttributeError, ((boost::format("list[%d] was not a vector") % i).str().c_str())); return PY_SET_ATTR_FAIL; } } @@ -556,7 +558,7 @@ RAS_IDisplayArray *KX_VertexProxy::GetDisplayArray() } // stuff for cvalue related things -STR_String KX_VertexProxy::GetName() +std::string KX_VertexProxy::GetName() { return "vertex"; } diff --git a/source/gameengine/Ketsji/KX_VertexProxy.h b/source/gameengine/Ketsji/KX_VertexProxy.h index eff946c3c575..9f37b5652a5a 100644 --- a/source/gameengine/Ketsji/KX_VertexProxy.h +++ b/source/gameengine/Ketsji/KX_VertexProxy.h @@ -55,7 +55,7 @@ class KX_VertexProxy : public CValue RAS_IDisplayArray *GetDisplayArray(); // stuff for cvalue related things - STR_String GetName(); + std::string GetName(); static PyObject *pyattr_get_x(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); static PyObject *pyattr_get_y(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); diff --git a/source/gameengine/Ketsji/KX_VisibilityActuator.cpp b/source/gameengine/Ketsji/KX_VisibilityActuator.cpp index 280eaee3e5af..68a939a6876f 100644 --- a/source/gameengine/Ketsji/KX_VisibilityActuator.cpp +++ b/source/gameengine/Ketsji/KX_VisibilityActuator.cpp @@ -120,7 +120,7 @@ PyAttributeDef KX_VisibilityActuator::Attributes[] = { KX_PYATTRIBUTE_BOOL_RW("visibility", KX_VisibilityActuator, m_visible), KX_PYATTRIBUTE_BOOL_RW("useOcclusion", KX_VisibilityActuator, m_occlusion), KX_PYATTRIBUTE_BOOL_RW("useRecursion", KX_VisibilityActuator, m_recursive), - { NULL } //Sentinel + KX_PYATTRIBUTE_NULL //Sentinel }; #endif // WITH_PYTHON diff --git a/source/gameengine/Ketsji/KX_WorldInfo.cpp b/source/gameengine/Ketsji/KX_WorldInfo.cpp index 87ad86be65c7..b85598699e49 100644 --- a/source/gameengine/Ketsji/KX_WorldInfo.cpp +++ b/source/gameengine/Ketsji/KX_WorldInfo.cpp @@ -94,7 +94,7 @@ KX_WorldInfo::~KX_WorldInfo() } } -const STR_String& KX_WorldInfo::GetName() +const std::string& KX_WorldInfo::GetName() { return m_name; } @@ -259,7 +259,7 @@ void KX_WorldInfo::RenderBackground(RAS_IRasterizer *rasty) * ------------------------------------------------------------------------- */ PyObject *KX_WorldInfo::py_repr(void) { - return PyUnicode_From_STR_String(GetName()); + return PyUnicode_FromStdString(GetName()); } /* ------------------------------------------------------------------------- @@ -307,7 +307,7 @@ PyAttributeDef KX_WorldInfo::Attributes[] = { KX_PYATTRIBUTE_RW_FUNCTION("ambientColor", KX_WorldInfo, pyattr_get_ambient_color, pyattr_set_ambient_color), KX_PYATTRIBUTE_FLOAT_RW("exposure", 0.0f, 1.0f, KX_WorldInfo, m_exposure), KX_PYATTRIBUTE_FLOAT_RW("range", 0.2f, 5.0f, KX_WorldInfo, m_range), - { NULL } /* Sentinel */ + KX_PYATTRIBUTE_NULL /* Sentinel */ }; /* Attribute get/set functions */ @@ -478,15 +478,15 @@ PyObject *KX_WorldInfo::pyattr_get_mist_typeconst(void *self_v, const KX_PYATTRI { PyObject *retvalue; - const char* type = attrdef->m_name; + const std::string& type = attrdef->m_name; - if (!strcmp(type, "KX_MIST_QUADRATIC")) { + if (type == "KX_MIST_QUADRATIC") { retvalue = PyLong_FromLong(KX_MIST_QUADRATIC); } - else if (!strcmp(type, "KX_MIST_LINEAR")) { + else if (type == "KX_MIST_LINEAR") { retvalue = PyLong_FromLong(KX_MIST_LINEAR); } - else if (!strcmp(type, "KX_MIST_INV_QUADRATIC")) { + else if (type == "KX_MIST_INV_QUADRATIC") { retvalue = PyLong_FromLong(KX_MIST_INV_QUADRATIC); } else { diff --git a/source/gameengine/Ketsji/KX_WorldInfo.h b/source/gameengine/Ketsji/KX_WorldInfo.h index db0f475f747c..ec73c84ee0d6 100644 --- a/source/gameengine/Ketsji/KX_WorldInfo.h +++ b/source/gameengine/Ketsji/KX_WorldInfo.h @@ -48,7 +48,7 @@ class KX_WorldInfo : public PyObjectPlus { Py_Header - STR_String m_name; + std::string m_name; Scene *m_scene; bool m_do_color_management; bool m_hasworld; @@ -84,7 +84,7 @@ class KX_WorldInfo : public PyObjectPlus MT_Vector3 zenithColor; } m_savedData; - const STR_String& GetName(); + const std::string& GetName(); bool hasWorld(); void setUseMist(bool enable); void setMistType(short type); diff --git a/source/gameengine/Launcher/LA_Launcher.cpp b/source/gameengine/Launcher/LA_Launcher.cpp index 1b87d6bdc9e9..63e558b51124 100644 --- a/source/gameengine/Launcher/LA_Launcher.cpp +++ b/source/gameengine/Launcher/LA_Launcher.cpp @@ -129,7 +129,7 @@ GlobalSettings *LA_Launcher::GetGlobalSettings() return m_ketsjiEngine->GetGlobalSettings(); } -const STR_String& LA_Launcher::GetExitString() +const std::string& LA_Launcher::GetExitString() { return m_exitString; } @@ -259,16 +259,15 @@ void LA_Launcher::InitEngine() InitCamera(); #ifdef WITH_PYTHON - KX_SetMainPath(STR_String(m_maggie->name)); + KX_SetMainPath(std::string(m_maggie->name)); #endif // Create a scene converter, create and convert the stratingscene. m_sceneConverter = new KX_BlenderSceneConverter(m_maggie, m_ketsjiEngine); - STR_String m_kxStartScenename = m_startSceneName.Ptr(); m_ketsjiEngine->SetSceneConverter(m_sceneConverter); m_kxStartScene = new KX_Scene(m_inputDevice, - m_kxStartScenename, + m_startSceneName, m_startScene, m_canvas, m_networkMessageManager); diff --git a/source/gameengine/Launcher/LA_Launcher.h b/source/gameengine/Launcher/LA_Launcher.h index f41c0a9bba32..941791b626d9 100644 --- a/source/gameengine/Launcher/LA_Launcher.h +++ b/source/gameengine/Launcher/LA_Launcher.h @@ -34,7 +34,7 @@ #include "SCA_IInputDevice.h" -#include "STR_String.h" +#include class KX_Scene; class KX_ISystem; @@ -52,14 +52,14 @@ class LA_Launcher { protected: /// \section The game data. - STR_String m_startSceneName; + std::string m_startSceneName; Scene *m_startScene; Main *m_maggie; KX_Scene *m_kxStartScene; /// \section Exit state. int m_exitRequested; - STR_String m_exitString; + std::string m_exitString; GlobalSettings *m_globalSettings; /// GHOST system abstraction. @@ -142,7 +142,7 @@ class LA_Launcher #endif // WITH_PYTHON int GetExitRequested(); - const STR_String& GetExitString(); + const std::string& GetExitString(); GlobalSettings *GetGlobalSettings(); inline KX_Scene *GetStartScene() const diff --git a/source/gameengine/Launcher/LA_SystemCommandLine.cpp b/source/gameengine/Launcher/LA_SystemCommandLine.cpp index 0b938bf79477..5b76e2069916 100644 --- a/source/gameengine/Launcher/LA_SystemCommandLine.cpp +++ b/source/gameengine/Launcher/LA_SystemCommandLine.cpp @@ -26,15 +26,15 @@ * \ingroup blroutines */ -#include "STR_HashedString.h" +#include #include "LA_SystemCommandLine.h" #include struct SingletonSystem { - std::map int_params; - std::map float_params; - std::map string_params; + std::map int_params; + std::map float_params; + std::map string_params; }; static SingletonSystem *_system_instance = NULL; @@ -57,7 +57,7 @@ void SYS_DeleteSystem(SYS_SystemHandle sys) int SYS_GetCommandLineInt(SYS_SystemHandle sys, const char *paramname, int defaultvalue) { - std::map::iterator it = ((SingletonSystem *)sys)->int_params.find(paramname); + std::map::iterator it = ((SingletonSystem *)sys)->int_params.find(paramname); if (it != ((SingletonSystem *)sys)->int_params.end()) { return it->second; } @@ -67,7 +67,7 @@ int SYS_GetCommandLineInt(SYS_SystemHandle sys, const char *paramname, int defau float SYS_GetCommandLineFloat(SYS_SystemHandle sys, const char *paramname, float defaultvalue) { - std::map::iterator it = ((SingletonSystem *)sys)->float_params.find(paramname); + std::map::iterator it = ((SingletonSystem *)sys)->float_params.find(paramname); if (it != ((SingletonSystem *)sys)->float_params.end()) { return it->second; } @@ -77,9 +77,9 @@ float SYS_GetCommandLineFloat(SYS_SystemHandle sys, const char *paramname, float const char *SYS_GetCommandLineString(SYS_SystemHandle sys, const char *paramname, const char *defaultvalue) { - std::map::iterator it = ((SingletonSystem *)sys)->string_params.find(paramname); + std::map::iterator it = ((SingletonSystem *)sys)->string_params.find(paramname); if (it != ((SingletonSystem *)sys)->string_params.end()) { - return it->second; + return it->second.c_str(); } return defaultvalue; diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp index 428ed4b95a48..13be0874c984 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp @@ -2826,7 +2826,7 @@ float CcdPhysicsEnvironment::getAppliedImpulse(int constraintid) return 0.0f; } -void CcdPhysicsEnvironment::ExportFile(const char *filename) +void CcdPhysicsEnvironment::ExportFile(const std::string& filename) { btDefaultSerializer *serializer = new btDefaultSerializer(); @@ -2835,16 +2835,16 @@ void CcdPhysicsEnvironment::ExportFile(const char *filename) CcdPhysicsController *controller = static_cast(colObj->getUserPointer()); if (controller) { - const char *name = KX_GameObject::GetClientObject((KX_ClientObjectInfo *)controller->GetNewClientInfo())->GetName(); - if (name) { - serializer->registerNameForPointer(colObj, name); + const std::string name = KX_GameObject::GetClientObject((KX_ClientObjectInfo *)controller->GetNewClientInfo())->GetName(); + if (!name.empty()) { + serializer->registerNameForPointer(colObj, name.c_str()); } } } m_dynamicsWorld->serialize(serializer); - FILE *file = fopen(filename, "wb"); + FILE *file = fopen(filename.c_str(), "wb"); if (file) { fwrite(serializer->getBufferPointer(), serializer->getCurrentBufferSize(), 1, file); fclose(file); diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h index b7e79ffbc2a4..3debafa04f53 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h @@ -323,7 +323,7 @@ class CcdPhysicsEnvironment : public PHY_IPhysicsEnvironment class btDispatcher *m_ownDispatcher; - virtual void ExportFile(const char *filename); + virtual void ExportFile(const std::string& filename); #ifdef WITH_CXX_GUARDEDALLOC MEM_CXX_CLASS_ALLOC_FUNCS("GE:CcdPhysicsEnvironment") diff --git a/source/gameengine/Physics/Common/PHY_IPhysicsEnvironment.h b/source/gameengine/Physics/Common/PHY_IPhysicsEnvironment.h index 4cb0d13440b4..86f7c7951877 100644 --- a/source/gameengine/Physics/Common/PHY_IPhysicsEnvironment.h +++ b/source/gameengine/Physics/Common/PHY_IPhysicsEnvironment.h @@ -231,7 +231,7 @@ class PHY_IPhysicsEnvironment virtual void SetConstraintParam(int constraintId, int param, float value, float value1) = 0; virtual float GetConstraintParam(int constraintId, int param) = 0; - virtual void ExportFile(const char *filename) + virtual void ExportFile(const std::string& filename) { }; diff --git a/source/gameengine/Rasterizer/RAS_2DFilter.cpp b/source/gameengine/Rasterizer/RAS_2DFilter.cpp index 9da8cc1a6f34..192ee4546c2d 100644 --- a/source/gameengine/Rasterizer/RAS_2DFilter.cpp +++ b/source/gameengine/Rasterizer/RAS_2DFilter.cpp @@ -61,7 +61,7 @@ RAS_2DFilter::RAS_2DFilter(RAS_2DFilterData& data) m_textures[i] = 0; } - m_progs[VERTEX_PROGRAM] = STR_String(datatoc_RAS_VertexShader2DFilter_glsl); + m_progs[VERTEX_PROGRAM] = std::string(datatoc_RAS_VertexShader2DFilter_glsl); m_progs[FRAGMENT_PROGRAM] = data.shaderText; LinkProgram(); @@ -141,9 +141,9 @@ void RAS_2DFilter::ParseShaderProgram() } if (m_gameObject) { - std::vector foundProperties; - for (std::vector::iterator it = m_properties.begin(), end = m_properties.end(); it != end; ++it) { - STR_String prop = *it; + std::vector foundProperties; + for (std::vector::iterator it = m_properties.begin(), end = m_properties.end(); it != end; ++it) { + std::string prop = *it; unsigned int loc = GetUniformLocation(prop, false); if (loc != -1) { m_propertiesLoc.push_back(loc); @@ -234,7 +234,7 @@ void RAS_2DFilter::BindUniforms(RAS_ICanvas *canvas) } for (unsigned int i = 0, size = m_properties.size(); i < size; ++i) { - const STR_String& prop = m_properties[i]; + const std::string& prop = m_properties[i]; unsigned int uniformLoc = m_propertiesLoc[i]; CValue *property = m_gameObject->GetProperty(prop); diff --git a/source/gameengine/Rasterizer/RAS_2DFilter.h b/source/gameengine/Rasterizer/RAS_2DFilter.h index 5c9b57177268..a5b0c075f777 100644 --- a/source/gameengine/Rasterizer/RAS_2DFilter.h +++ b/source/gameengine/Rasterizer/RAS_2DFilter.h @@ -46,7 +46,7 @@ class RAS_2DFilter : public virtual RAS_Shader protected: int m_predefinedUniforms[MAX_PREDEFINED_UNIFORM_TYPE]; - std::vector m_properties; + std::vector m_properties; std::vector m_propertiesLoc; CValue *m_gameObject; diff --git a/source/gameengine/Rasterizer/RAS_2DFilterData.cpp b/source/gameengine/Rasterizer/RAS_2DFilterData.cpp index 4468ce1c3c1c..71019fa7a0f1 100644 --- a/source/gameengine/Rasterizer/RAS_2DFilterData.cpp +++ b/source/gameengine/Rasterizer/RAS_2DFilterData.cpp @@ -20,7 +20,7 @@ * ***** END GPL LICENSE BLOCK ***** */ #include "RAS_2DFilterData.h" -#include "STR_String.h" +#include RAS_2DFilterData::RAS_2DFilterData() :gameObject(NULL), diff --git a/source/gameengine/Rasterizer/RAS_2DFilterData.h b/source/gameengine/Rasterizer/RAS_2DFilterData.h index 0f1df11e0021..739438fdad9d 100644 --- a/source/gameengine/Rasterizer/RAS_2DFilterData.h +++ b/source/gameengine/Rasterizer/RAS_2DFilterData.h @@ -24,7 +24,7 @@ #define __RAS_2DFILTERDATA__ #include -#include "STR_String.h" +#include class CValue; @@ -40,7 +40,7 @@ class RAS_2DFilterData virtual ~RAS_2DFilterData(); /// The names of the properties of the game object that the shader may want to use as uniforms. - std::vector propertyNames; + std::vector propertyNames; /// The KX_GameObject (or something else?) that provides the values for the uniforms named above. CValue *gameObject; /// Should be a SCA_2DFilterActuator.FILTER_MODE value. @@ -48,7 +48,7 @@ class RAS_2DFilterData /// In the original design this was bot the pass index and the unique identifier of the filter in the filter manager. unsigned int filterPassIndex; /// This is the shader program source code IF the filter is not a predefined one. - STR_String shaderText; + std::string shaderText; }; #endif // __RAS_2DFILTERDATA__ diff --git a/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp index 682395eaec10..464b85fa8ab4 100644 --- a/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp +++ b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp @@ -142,7 +142,7 @@ void RAS_2DFilterManager::RenderFilters(RAS_IRasterizer *rasty, RAS_ICanvas *can RAS_2DFilter *RAS_2DFilterManager::CreateFilter(RAS_2DFilterData& filterData) { RAS_2DFilter *result = NULL; - const char *shaderSource = NULL; + std::string shaderSource; switch(filterData.filterMode) { case RAS_2DFilterManager::FILTER_MOTIONBLUR: break; @@ -177,7 +177,7 @@ RAS_2DFilter *RAS_2DFilterManager::CreateFilter(RAS_2DFilterData& filterData) shaderSource = datatoc_RAS_Invert2DFilter_glsl; break; } - if (!shaderSource) { + if (shaderSource.empty()) { if(filterData.filterMode == RAS_2DFilterManager::FILTER_CUSTOMFILTER) { result = NewFilter(filterData); } diff --git a/source/gameengine/Rasterizer/RAS_ICanvas.h b/source/gameengine/Rasterizer/RAS_ICanvas.h index 8a23b0f73d68..1100a4f04388 100644 --- a/source/gameengine/Rasterizer/RAS_ICanvas.h +++ b/source/gameengine/Rasterizer/RAS_ICanvas.h @@ -137,7 +137,7 @@ class RAS_ICanvas return m_mousestate; } - virtual void MakeScreenShot(const char *filename) = 0; + virtual void MakeScreenShot(const std::string& filename) = 0; virtual void GetDisplayDimensions(int &width, int &height) = 0; diff --git a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp b/source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp index c4b1e2e3db6b..ae5916b24c98 100644 --- a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp +++ b/source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp @@ -35,7 +35,7 @@ #include "DNA_material_types.h" RAS_IPolyMaterial::RAS_IPolyMaterial( - const STR_String& name, + const std::string& name, GameSettings *game) :m_name(name), m_alphablend(0), @@ -121,7 +121,7 @@ int RAS_IPolyMaterial::GetDrawingMode() const return m_drawingmode; } -STR_String RAS_IPolyMaterial::GetName() +std::string RAS_IPolyMaterial::GetName() { return m_name; } diff --git a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.h b/source/gameengine/Rasterizer/RAS_IPolygonMaterial.h index 038d41b03b25..aac98a73d24b 100644 --- a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.h +++ b/source/gameengine/Rasterizer/RAS_IPolygonMaterial.h @@ -36,7 +36,7 @@ #include "RAS_MeshObject.h" #include "RAS_IRasterizer.h" -#include "STR_String.h" +#include #ifdef WITH_CXX_GUARDEDALLOC #include "MEM_guardedalloc.h" @@ -80,7 +80,7 @@ enum MaterialRasterizerModes class RAS_IPolyMaterial { protected: - STR_String m_name; // also needed for collisionsensor + std::string m_name; // also needed for collisionsensor int m_drawingmode; int m_alphablend; int m_rasMode; @@ -98,7 +98,7 @@ class RAS_IPolyMaterial SHADOW = 2048 // GEMAT_SHADOW }; - RAS_IPolyMaterial(const STR_String& name, + RAS_IPolyMaterial(const std::string& name, GameSettings *game); virtual ~RAS_IPolyMaterial(); @@ -116,7 +116,7 @@ class RAS_IPolyMaterial bool IsText() const; bool IsCullFace() const; int GetDrawingMode() const; - virtual STR_String GetName(); + virtual std::string GetName(); unsigned int GetFlag() const; bool IsAlphaShadow() const; bool UsesObjectColor() const; @@ -125,7 +125,7 @@ class RAS_IPolyMaterial RAS_Texture *GetTexture(unsigned int index); bool UseDisplayLists() const; - virtual const STR_String GetTextureName() const = 0; + virtual const std::string GetTextureName() const = 0; virtual Material *GetBlenderMaterial() const = 0; virtual Image *GetBlenderImage() const = 0; virtual MTexPoly *GetMTexPoly() const = 0; diff --git a/source/gameengine/Rasterizer/RAS_IRasterizer.h b/source/gameengine/Rasterizer/RAS_IRasterizer.h index 7f1820b10666..a4c5b420d76e 100644 --- a/source/gameengine/Rasterizer/RAS_IRasterizer.h +++ b/source/gameengine/Rasterizer/RAS_IRasterizer.h @@ -36,7 +36,7 @@ # pragma warning (disable:4786) #endif -#include "STR_HashedString.h" +#include #include "MT_CmMatrix4x4.h" #include "MT_Matrix4x4.h" @@ -46,6 +46,7 @@ #endif #include +#include class RAS_ICanvas; class RAS_IPolyMaterial; @@ -667,7 +668,7 @@ class RAS_IRasterizer * \param aspect A scaling factor to compensate for the size. */ virtual void RenderText3D( - int fontid, const char *text, int size, int dpi, + int fontid, const std::string& text, int size, int dpi, const float color[4], const float mat[16], float aspect) = 0; /** @@ -680,7 +681,7 @@ class RAS_IRasterizer * \param height Height of the canvas to draw to. */ virtual void RenderText2D( - RAS_TEXT_RENDER_MODE mode, const char *text, + RAS_TEXT_RENDER_MODE mode, const std::string& text, int xco, int yco, int width, int height) = 0; virtual void ProcessLighting(bool uselights, const MT_Transform &trans) = 0; diff --git a/source/gameengine/Rasterizer/RAS_MeshObject.cpp b/source/gameengine/Rasterizer/RAS_MeshObject.cpp index 6e91851af57e..2f465a5aee15 100644 --- a/source/gameengine/Rasterizer/RAS_MeshObject.cpp +++ b/source/gameengine/Rasterizer/RAS_MeshObject.cpp @@ -129,7 +129,7 @@ int RAS_MeshObject::NumMaterials() return m_materials.size(); } -const STR_String RAS_MeshObject::GetMaterialName(unsigned int matid) +const std::string RAS_MeshObject::GetMaterialName(unsigned int matid) { RAS_MeshMaterial *mmat = GetMeshMaterial(matid); @@ -180,12 +180,12 @@ std::vector::iterator RAS_MeshObject::GetLastMaterial() return m_materials.end(); } -STR_String& RAS_MeshObject::GetName() +std::string& RAS_MeshObject::GetName() { return m_name; } -const STR_String RAS_MeshObject::GetTextureName(unsigned int matid) +const std::string RAS_MeshObject::GetTextureName(unsigned int matid) { RAS_MeshMaterial *mmat = GetMeshMaterial(matid); diff --git a/source/gameengine/Rasterizer/RAS_MeshObject.h b/source/gameengine/Rasterizer/RAS_MeshObject.h index c8b13828323c..859ac9a938c5 100644 --- a/source/gameengine/Rasterizer/RAS_MeshObject.h +++ b/source/gameengine/Rasterizer/RAS_MeshObject.h @@ -45,7 +45,7 @@ #include "RAS_Texture.h" #include "MT_Transform.h" #include "MT_Vector2.h" -#include "STR_String.h" +#include class RAS_MeshUser; class RAS_Deformer; @@ -74,7 +74,7 @@ class RAS_MeshObject /// The index of the color or uv layer in the vertices. unsigned short index; /// The name of the color or uv layer used to find corresponding material attributes. - STR_String name; + std::string name; }; typedef std::vector LayerList; @@ -88,7 +88,7 @@ class RAS_MeshObject }; private: - STR_String m_name; + std::string m_name; LayersInfo m_layersInfo; @@ -113,8 +113,8 @@ class RAS_MeshObject // materials int NumMaterials(); - const STR_String GetMaterialName(unsigned int matid); - const STR_String GetTextureName(unsigned int matid); + const std::string GetMaterialName(unsigned int matid); + const std::string GetTextureName(unsigned int matid); RAS_MeshMaterial *GetMeshMaterial(unsigned int matid) const; RAS_MeshMaterial *GetMeshMaterialBlenderIndex(unsigned int index); @@ -123,7 +123,7 @@ class RAS_MeshObject std::vector::iterator GetLastMaterial(); // name - STR_String& GetName(); + std::string& GetName(); // original blender mesh Mesh *GetMesh() diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp index 490af6715512..10cddf55ecf4 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp @@ -2152,7 +2152,7 @@ void RAS_OpenGLRasterizer::RenderBox2D(int xco, } void RAS_OpenGLRasterizer::RenderText3D( - int fontid, const char *text, int size, int dpi, + int fontid, const std::string& text, int size, int dpi, const float color[4], const float mat[16], float aspect) { /* gl prepping */ @@ -2173,7 +2173,7 @@ void RAS_OpenGLRasterizer::RenderText3D( BLF_size(fontid, size, dpi); BLF_position(fontid, 0, 0, 0); - BLF_draw(fontid, text, 65535); + BLF_draw(fontid, text.c_str(), 65535); BLF_disable(fontid, BLF_MATRIX | BLF_ASPECT); @@ -2182,7 +2182,7 @@ void RAS_OpenGLRasterizer::RenderText3D( void RAS_OpenGLRasterizer::RenderText2D( RAS_TEXT_RENDER_MODE mode, - const char *text, + const std::string& text, int xco, int yco, int width, int height) { @@ -2208,14 +2208,14 @@ void RAS_OpenGLRasterizer::RenderText2D( glColor3ub(0, 0, 0); BLF_size(blf_mono_font, 11, 72); BLF_position(blf_mono_font, (float)xco + 1, (float)(height - yco - 1), 0.0f); - BLF_draw(blf_mono_font, text, 65535); /* XXX, use real len */ + BLF_draw(blf_mono_font, text.c_str(), 65535); /* XXX, use real len */ } /* the actual drawing */ glColor3ub(255, 255, 255); BLF_size(blf_mono_font, 11, 72); BLF_position(blf_mono_font, (float)xco, (float)(height - yco), 0.0f); - BLF_draw(blf_mono_font, text, 65535); /* XXX, use real len */ + BLF_draw(blf_mono_font, text.c_str(), 65535); /* XXX, use real len */ SetMatrixMode(RAS_PROJECTION); PopMatrix(); diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h index c310556bce1d..ff46bf504f5a 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h @@ -383,9 +383,9 @@ class RAS_OpenGLRasterizer : public RAS_IRasterizer void DisableForText(); void RenderBox2D(int xco, int yco, int width, int height, float percentage); - void RenderText3D(int fontid, const char *text, int size, int dpi, + void RenderText3D(int fontid, const std::string& text, int size, int dpi, const float color[4], const float mat[16], float aspect); - void RenderText2D(RAS_TEXT_RENDER_MODE mode, const char *text, + void RenderText2D(RAS_TEXT_RENDER_MODE mode, const std::string& text, int xco, int yco, int width, int height); virtual void GetTransform(float *origmat, int objectdrawmode, float mat[16]); diff --git a/source/gameengine/Rasterizer/RAS_Shader.cpp b/source/gameengine/Rasterizer/RAS_Shader.cpp index c25eeebba7a0..7c28b039eb8f 100644 --- a/source/gameengine/Rasterizer/RAS_Shader.cpp +++ b/source/gameengine/Rasterizer/RAS_Shader.cpp @@ -30,6 +30,8 @@ #include "GPU_shader.h" +#include // for memcpy + #include "CM_Message.h" #define UNIFORM_MAX_LEN (int)sizeof(float) * 16 @@ -287,14 +289,14 @@ bool RAS_Shader::LinkProgram() goto program_error; } - if (m_progs[VERTEX_PROGRAM].IsEmpty() || m_progs[FRAGMENT_PROGRAM].IsEmpty()) { + if (m_progs[VERTEX_PROGRAM].empty() || m_progs[FRAGMENT_PROGRAM].empty()) { CM_Error("invalid GLSL sources"); return false; } - vert = m_progs[VERTEX_PROGRAM].ReadPtr(); - frag = m_progs[FRAGMENT_PROGRAM].ReadPtr(); - geom = (m_progs[GEOMETRY_PROGRAM] == "") ? NULL : m_progs[GEOMETRY_PROGRAM].ReadPtr(); + vert = m_progs[VERTEX_PROGRAM].c_str(); + frag = m_progs[FRAGMENT_PROGRAM].c_str(); + geom = (m_progs[GEOMETRY_PROGRAM].empty()) ? NULL : m_progs[GEOMETRY_PROGRAM].c_str(); m_shader = GPU_shader_create_ex(vert, frag, geom, NULL, NULL, 0, 0, 0, GPU_SHADER_FLAGS_SPECIAL_RESET_LINE); if (!m_shader) { goto program_error; @@ -466,20 +468,20 @@ int RAS_Shader::GetAttribute() return m_attr; } -int RAS_Shader::GetAttribLocation(const char *name) +int RAS_Shader::GetAttribLocation(const std::string& name) { - return GPU_shader_get_attribute(m_shader, name); + return GPU_shader_get_attribute(m_shader, name.c_str()); } -void RAS_Shader::BindAttribute(const char *attr, int loc) +void RAS_Shader::BindAttribute(const std::string& attr, int loc) { - GPU_shader_bind_attribute(m_shader, loc, attr); + GPU_shader_bind_attribute(m_shader, loc, attr.c_str()); } -int RAS_Shader::GetUniformLocation(const char *name, bool debug) +int RAS_Shader::GetUniformLocation(const std::string& name, bool debug) { BLI_assert(m_shader != NULL); - int location = GPU_shader_get_uniform(m_shader, name); + int location = GPU_shader_get_uniform(m_shader, name.c_str()); if (location == -1 && debug) { CM_Error("invalid uniform value: " << name << "."); diff --git a/source/gameengine/Rasterizer/RAS_Shader.h b/source/gameengine/Rasterizer/RAS_Shader.h index 0cb5a5b5d035..b2226873e6b0 100644 --- a/source/gameengine/Rasterizer/RAS_Shader.h +++ b/source/gameengine/Rasterizer/RAS_Shader.h @@ -8,7 +8,7 @@ #include "MT_Matrix4x4.h" -#include "STR_String.h" +#include #include @@ -106,7 +106,7 @@ class RAS_Shader bool m_ok; // Valid and ok bool m_use; int m_attr; // Tangent attribute - STR_String m_progs[MAX_PROGRAM]; + std::string m_progs[MAX_PROGRAM]; bool m_error; bool m_dirty; @@ -172,14 +172,14 @@ class RAS_Shader void SetUniformfv(int location, int type, float *param, int size, unsigned int count, bool transpose = false); void SetUniformiv(int location, int type, int *param, int size, unsigned int count, bool transpose = false); - int GetAttribLocation(const char *name); - void BindAttribute(const char *attr, int loc); + int GetAttribLocation(const std::string& name); + void BindAttribute(const std::string& attr, int loc); /** Return uniform location in the shader. * \param name The uniform name. * \param debug Print message for unfound coresponding uniform name. */ - int GetUniformLocation(const char *name, bool debug=true); + int GetUniformLocation(const std::string& name, bool debug=true); void SetUniform(int uniform, const MT_Vector2 &vec); void SetUniform(int uniform, const MT_Vector3 &vec); diff --git a/source/gameengine/Rasterizer/RAS_TextUser.cpp b/source/gameengine/Rasterizer/RAS_TextUser.cpp index 61875394116d..7bf74d31327a 100644 --- a/source/gameengine/Rasterizer/RAS_TextUser.cpp +++ b/source/gameengine/Rasterizer/RAS_TextUser.cpp @@ -74,7 +74,7 @@ const MT_Vector3& RAS_TextUser::GetSpacing() const return m_spacing; } -const std::vector& RAS_TextUser::GetTexts() const +const std::vector& RAS_TextUser::GetTexts() const { return m_texts; } @@ -109,7 +109,7 @@ void RAS_TextUser::SetSpacing(const MT_Vector3& spacing) m_spacing = spacing; } -void RAS_TextUser::SetTexts(const std::vector& texts) +void RAS_TextUser::SetTexts(const std::vector& texts) { m_texts = texts; } diff --git a/source/gameengine/Rasterizer/RAS_TextUser.h b/source/gameengine/Rasterizer/RAS_TextUser.h index b49cb99b8ca9..e451c42c1d28 100644 --- a/source/gameengine/Rasterizer/RAS_TextUser.h +++ b/source/gameengine/Rasterizer/RAS_TextUser.h @@ -31,12 +31,12 @@ #include "RAS_MeshUser.h" -#include "STR_String.h" +#include class RAS_TextUser : public RAS_MeshUser { private: - std::vector m_texts; + std::vector m_texts; int m_fontid; int m_size; int m_dpi; @@ -55,7 +55,7 @@ class RAS_TextUser : public RAS_MeshUser float GetAspect() const; const MT_Vector3& GetOffset() const; const MT_Vector3& GetSpacing() const; - const std::vector& GetTexts() const; + const std::vector& GetTexts() const; void SetFontId(int fontid); void SetSize(int size); @@ -63,7 +63,7 @@ class RAS_TextUser : public RAS_MeshUser void SetAspect(float aspect); void SetOffset(const MT_Vector3& offset); void SetSpacing(const MT_Vector3& spacing); - void SetTexts(const std::vector& texts); + void SetTexts(const std::vector& texts); }; #endif // __RAS_TEXT_USER_H__ diff --git a/source/gameengine/Rasterizer/RAS_Texture.cpp b/source/gameengine/Rasterizer/RAS_Texture.cpp index 85d0a4e858ec..93b20080d863 100644 --- a/source/gameengine/Rasterizer/RAS_Texture.cpp +++ b/source/gameengine/Rasterizer/RAS_Texture.cpp @@ -38,7 +38,7 @@ RAS_Texture::~RAS_Texture() { } -STR_String& RAS_Texture::GetName() +std::string& RAS_Texture::GetName() { return m_name; } diff --git a/source/gameengine/Rasterizer/RAS_Texture.h b/source/gameengine/Rasterizer/RAS_Texture.h index 4d8b058e6fc3..8c14de0a6465 100644 --- a/source/gameengine/Rasterizer/RAS_Texture.h +++ b/source/gameengine/Rasterizer/RAS_Texture.h @@ -25,7 +25,7 @@ #ifndef __RAS_TEXTURE_H__ #define __RAS_TEXTURE_H__ -#include "STR_String.h" +#include struct MTex; struct Tex; @@ -38,7 +38,7 @@ class RAS_Texture { protected: int m_bindCode; - STR_String m_name; + std::string m_name; RAS_CubeMap *m_cubeMap; @@ -53,7 +53,7 @@ class RAS_Texture virtual Tex *GetTex() const = 0; virtual Image *GetImage() const = 0; virtual GPUTexture *GetGPUTexture() const = 0; - STR_String& GetName(); + std::string& GetName(); void SetCubeMap(RAS_CubeMap *cubeMap); RAS_CubeMap *GetCubeMap() const; diff --git a/source/gameengine/VideoTexture/Texture.cpp b/source/gameengine/VideoTexture/Texture.cpp index 474bdec49802..72537059ed98 100644 --- a/source/gameengine/VideoTexture/Texture.cpp +++ b/source/gameengine/VideoTexture/Texture.cpp @@ -106,7 +106,7 @@ void Texture::DestructFromPython() PyObjectPlus::DestructFromPython(); } -STR_String Texture::GetName() +std::string Texture::GetName() { return "Texture"; } @@ -232,12 +232,12 @@ short getMaterialID(PyObject *obj, const char *name) // name is a material name if it starts with MA and a UV texture name if it starts with IM if (name[0] == 'I' && name[1] == 'M') { // if texture name matches - if (strcmp(mat->GetTextureName().ReadPtr(), name) == 0) + if (mat->GetTextureName() == name) return matID; } else { // if material name matches - if (strcmp(mat->GetName().ReadPtr(), name) == 0) + if (mat->GetName() == name) return matID; } } @@ -528,7 +528,7 @@ PyAttributeDef Texture::Attributes[] = { KX_PYATTRIBUTE_RW_FUNCTION("mipmap", Texture, pyattr_get_mipmap, pyattr_set_mipmap), KX_PYATTRIBUTE_RW_FUNCTION("source", Texture, pyattr_get_source, pyattr_set_source), KX_PYATTRIBUTE_RO_FUNCTION("bindId", Texture, pyattr_get_bindId), - {NULL} + KX_PYATTRIBUTE_NULL }; diff --git a/source/gameengine/VideoTexture/Texture.h b/source/gameengine/VideoTexture/Texture.h index 654f44f422ff..b72a993b4b6a 100644 --- a/source/gameengine/VideoTexture/Texture.h +++ b/source/gameengine/VideoTexture/Texture.h @@ -87,7 +87,7 @@ class Texture : public CValue Texture(); virtual ~Texture(); - virtual STR_String GetName(); + virtual std::string GetName(); void Close(); void SetSource(PyImage *source); diff --git a/source/gameengine/VideoTexture/VideoFFmpeg.cpp b/source/gameengine/VideoTexture/VideoFFmpeg.cpp index 083e9e28502b..53378f762ee7 100644 --- a/source/gameengine/VideoTexture/VideoFFmpeg.cpp +++ b/source/gameengine/VideoTexture/VideoFFmpeg.cpp @@ -570,7 +570,7 @@ void VideoFFmpeg::openFile (char *filename) // the file is to be treated as an image, i.e. load the first frame only m_isFile = false; // in case of reload, the filename is taken from m_imageName, no need to change it - if (m_imageName.Ptr() != filename) + if (m_imageName.c_str() != filename) m_imageName = filename; m_preseek = 0; m_avail = false; diff --git a/source/gameengine/VideoTexture/VideoFFmpeg.h b/source/gameengine/VideoTexture/VideoFFmpeg.h index 0a49a0b19bbd..07eb50f84f41 100644 --- a/source/gameengine/VideoTexture/VideoFFmpeg.h +++ b/source/gameengine/VideoTexture/VideoFFmpeg.h @@ -102,7 +102,7 @@ class VideoFFmpeg : public VideoBase void setPreseek(int preseek) { if (preseek >= 0) m_preseek = preseek; } bool getDeinterlace(void) { return m_deinterlace; } void setDeinterlace(bool deinterlace) { m_deinterlace = deinterlace; } - char *getImageName(void) { return (m_isImage) ? m_imageName.Ptr() : NULL; } + char *getImageName(void) { return (m_isImage) ? (char *)m_imageName.c_str() : NULL; } protected: // format and codec information @@ -161,7 +161,7 @@ class VideoFFmpeg : public VideoBase bool m_isStreaming; /// keep last image name - STR_String m_imageName; + std::string m_imageName; /// image calculation virtual void calcImage (unsigned int texId, double ts);