Commit 27406442 authored by Byurrrer's avatar Byurrrer

Добавил эмбиент звуки на уровень (тестовый вариант), изменил сравнение строк в...

Добавил эмбиент звуки на уровень (тестовый вариант), изменил сравнение строк в конфигах на "без учета регистра", добавил игровой объект "точечный свет", чуток почистил либу света, поправил загрузку материалов, сделал обновление позиции и поворотов игрового объекта при изменении хелпером
parent 25db5741
This diff is collapsed.
......@@ -105,6 +105,7 @@
<ClCompile Include="..\..\..\source\game\SXbaseTool.cpp" />
<ClCompile Include="..\..\..\source\game\SXbaseWeapon.cpp" />
<ClCompile Include="..\..\..\source\game\sxgame_dll.cpp" />
<ClCompile Include="..\..\..\source\game\SXLightPoint.cpp" />
<ClCompile Include="..\..\..\source\game\SXplayer.cpp" />
<ClCompile Include="..\..\..\source\game\SXplayerSpawn.cpp" />
<ClCompile Include="..\..\..\source\game\SXpointCamera.cpp" />
......@@ -129,6 +130,7 @@
<ClInclude Include="..\..\..\source\game\SXbaseTool.h" />
<ClInclude Include="..\..\..\source\game\SXbaseWeapon.h" />
<ClInclude Include="..\..\..\source\game\sxgame.h" />
<ClInclude Include="..\..\..\source\game\SXLightPoint.h" />
<ClInclude Include="..\..\..\source\game\SXplayer.h" />
<ClInclude Include="..\..\..\source\game\SXplayerSpawn.h" />
<ClInclude Include="..\..\..\source\game\SXpointCamera.h" />
......
......@@ -99,6 +99,9 @@
<ClCompile Include="..\..\..\source\game\SXbaseWeapon.cpp">
<Filter>Source Files\ents\items\tools</Filter>
</ClCompile>
<ClCompile Include="..\..\..\source\game\SXLightPoint.cpp">
<Filter>Source Files\ents</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\source\game\sxgame.h">
......@@ -167,5 +170,8 @@
<ClInclude Include="..\..\..\source\game\SXbaseWeapon.h">
<Filter>Header Files\ents\items\tools</Filter>
</ClInclude>
<ClInclude Include="..\..\..\source\game\SXLightPoint.h">
<Filter>Header Files\ents</Filter>
</ClInclude>
</ItemGroup>
</Project>
\ No newline at end of file
......@@ -3,12 +3,69 @@
#pragma once
class ConfigString : public String
{
public:
ConfigString() : String(){}
ConfigString(const char * str) : String(str){}
ConfigString(const String & str) : String(str){}
ConfigString(const ConfigString & str) : String(str){}
ConfigString(const ConfigString * str) : String(str){}
ConfigString(const char sym) : String(sym){}
~ConfigString() {}
const char & operator[](const unsigned long & num) const
{
return(this->string[num]);
}
char & operator[](const unsigned long & num)
{
return(this->string[num]);
}
ConfigString & operator=(const ConfigString & str)
{
Release();
string = new char[str.length() + 1];
memcpy(string, str.c_str(), str.length() + 1);
return(*this);
}
ConfigString & operator=(const ConfigString * str)
{
Release();
string = new char[str->length() + 1];
memcpy(string, str->c_str(), str->length() + 1);
return(*this);
}
bool operator==(const ConfigString &str) const
{
return (stricmp(str.string, this->string) == 0);
}
bool operator==(const ConfigString * str) const
{
return (stricmp(str->string, this->string) == 0);
}
ConfigString & operator+=(const char & sym)
{
char * newstring = new char[length() + 2];
sprintf(newstring, "%s%c", string, sym);
SAFE_DELETE_A(string);
string = newstring;
return(*this);
}
};
class SXLoaderConfig : public ISXLConfig
{
public:
struct value
{
String val;
ConfigString val;
bool isModified;
value():isModified(false)
{
......@@ -16,10 +73,10 @@ public:
};
struct section
{
String parent;
AssotiativeArray<String, value> mValues;
ConfigString parent;
AssotiativeArray<ConfigString, value> mValues;
bool native;
String Include;
ConfigString Include;
bool isModified;
section():isModified(false)
{
......@@ -48,45 +105,45 @@ public:
void Release();
void Clear();
AssotiativeArray<String, section> * GetSections();
AssotiativeArray<ConfigString, section> * GetSections();
//inline const char* GetPath();
const char* GetErrorFile();
protected:
String ErrorFile;
ConfigString ErrorFile;
struct include
{
String name;
ConfigString name;
SXLoaderConfig *pParser;
};
String BaseFile;
ConfigString BaseFile;
//protected:
AssotiativeArray<String, value> m_mFinalValues;
AssotiativeArray<ConfigString, value> m_mFinalValues;
AssotiativeArray<String, section> m_mSections;
AssotiativeArray<ConfigString, section> m_mSections;
Array<include> m_vIncludes;
//public:
int WriteFile(const String & name, String section, String key, const String & val);
int WriteFile(const ConfigString & name, ConfigString section, ConfigString key, const ConfigString & val);
int Parse(const char* file);
int ParseInclude(String & file, const String & dir);
int ParseInclude(ConfigString & file, const ConfigString & dir);
String GetIncludeName(int i);
ConfigString GetIncludeName(int i);
String BaseDir(String dir);
String BaseName(String dir);
ConfigString BaseDir(ConfigString dir);
ConfigString BaseName(ConfigString dir);
void Modify(AssotiativeArray<String, section> & sections, AssotiativeArray<String, value> & values, String IncName);
void Modify(AssotiativeArray<ConfigString, section> & sections, AssotiativeArray<ConfigString, value> & values, ConfigString IncName);
};
#endif
#include <common\\AssotiativeArray.h>
#include <common\\string.cpp>
#include <common\\String.cpp>
#include <core\\LoaderConfig.h>
#pragma once
/*
......@@ -26,7 +26,7 @@ void SXLoaderConfig::New(const char* path)
BaseFile = path;
}
String SXLoaderConfig::BaseDir(String dir)
ConfigString SXLoaderConfig::BaseDir(ConfigString dir)
{
int p1 = dir.find_last_of('/');
int p2 = dir.find_last_of('\\');
......@@ -41,7 +41,7 @@ String SXLoaderConfig::BaseDir(String dir)
}
}
String SXLoaderConfig::BaseName(String dir)
ConfigString SXLoaderConfig::BaseName(ConfigString dir)
{
int p1 = dir.find_last_of('/');
int p2 = dir.find_last_of('\\');
......@@ -59,7 +59,7 @@ String SXLoaderConfig::BaseName(String dir)
int SXLoaderConfig::Parse(const char* file)
{
Clear();
BaseFile = String(file);
BaseFile = ConfigString(file);
FILE * fp = fopen(file, "rb");
if(!fp)
{
......@@ -76,10 +76,10 @@ int SXLoaderConfig::Parse(const char* file)
bool bFirstChar = true;
bool bSectionNameDone = false;
String s1 = ""; // some
String s2 = ""; // section
String s3 = ""; // parentS
String s4 = ""; // val
ConfigString s1 = ""; // some
ConfigString s2 = ""; // section
ConfigString s3 = ""; // parentS
ConfigString s4 = ""; // val
......@@ -139,9 +139,9 @@ int SXLoaderConfig::Parse(const char* file)
m_mSections[s2].native = true;
if(m_mSections.KeyExists(s3))
{
for(AssotiativeArray<String, value>::Iterator i = m_mSections[s3].mValues.begin(); i; i++)
for(AssotiativeArray<ConfigString, value>::Iterator i = m_mSections[s3].mValues.begin(); i; i++)
{
m_mSections[s2].mValues[i.first].val = i.second;
m_mSections[s2].mValues[i.first].val = i.second->val;
}
}
}
......@@ -174,9 +174,9 @@ int SXLoaderConfig::Parse(const char* file)
m_mSections[s2].native = true;
if(m_mSections.KeyExists(s3))
{
for(AssotiativeArray<String, value>::Iterator i = m_mSections[s3].mValues.begin(); i; i++)
for(AssotiativeArray<ConfigString, value>::Iterator i = m_mSections[s3].mValues.begin(); i; i++)
{
m_mSections[s2].mValues[i.first].val = i.second;
m_mSections[s2].mValues[i.first].val = i.second->val;
}
}
}
......@@ -317,14 +317,14 @@ int SXLoaderConfig::Parse(const char* file)
return 0;
}
void SXLoaderConfig::Modify(AssotiativeArray<String, section> & sections, AssotiativeArray<String, value> & values, String IncName)
void SXLoaderConfig::Modify(AssotiativeArray<ConfigString, section> & sections, AssotiativeArray<ConfigString, value> & values, ConfigString IncName)
{
for(AssotiativeArray<String, value>::Iterator i = m_mFinalValues.begin(); i; i++)
for(AssotiativeArray<ConfigString, value>::Iterator i = m_mFinalValues.begin(); i; i++)
{
values[i.first].val = i.second->val;
}
for(AssotiativeArray<String, section>::Iterator i = m_mSections.begin(); i; i++)
for(AssotiativeArray<ConfigString, section>::Iterator i = m_mSections.begin(); i; i++)
{
if(!sections.KeyExists(i.first))
{
......@@ -332,14 +332,14 @@ void SXLoaderConfig::Modify(AssotiativeArray<String, section> & sections, Assoti
sections[i.first].native = false;
sections[i.first].Include = IncName;
}
for(AssotiativeArray<String, value>::Iterator j = m_mSections[i.first].mValues.begin(); j; j++)
for(AssotiativeArray<ConfigString, value>::Iterator j = m_mSections[i.first].mValues.begin(); j; j++)
{
sections[i.first].mValues[j.first].val = j.second->val;
}
}
}
int SXLoaderConfig::ParseInclude(String & file, const String & dir)
int SXLoaderConfig::ParseInclude(ConfigString & file, const ConfigString & dir)
{
//printf("Parsing include %s fromdir = %s\n", file.c_str(), dir.c_str());
FILE * pF = fopen((dir + file).c_str(), "r");
......@@ -378,8 +378,8 @@ const char* SXLoaderConfig::GetErrorFile()
const char* SXLoaderConfig::GetKey(const char * section, const char * key)
{
String keys(key);
String sections(section);
ConfigString keys(key);
ConfigString sections(section);
if(m_mSections.KeyExists(sections))
{
if(m_mSections[sections].mValues.KeyExists(keys))
......@@ -393,14 +393,14 @@ const char* SXLoaderConfig::GetKey(const char * section, const char * key)
const char* SXLoaderConfig::GetKeyName(const char* section, int key)
{
//String keys(key);
String sections(section);
//ConfigString keys(key);
ConfigString sections(section);
if (m_mSections.KeyExists(sections))
{
if (m_mSections[sections].mValues.Size() > key)
{
int countiter = 0;
AssotiativeArray<String, SXLoaderConfig::value>::Iterator iter = m_mSections[sections].mValues.begin();
AssotiativeArray<ConfigString, SXLoaderConfig::value>::Iterator iter = m_mSections[sections].mValues.begin();
for (int i = 0; i < key && iter; i++)
{
iter++;
......@@ -419,7 +419,7 @@ const char* SXLoaderConfig::GetSectionName(int num)
if (m_mSections.Size() > num)
{
int countiter = 0;
AssotiativeArray<String, SXLoaderConfig::section>::Iterator iter = m_mSections.begin();
AssotiativeArray<ConfigString, SXLoaderConfig::section>::Iterator iter = m_mSections.begin();
for (int i = 0; i < num && iter; i++)
{
iter++;
......@@ -434,9 +434,9 @@ const char* SXLoaderConfig::GetSectionName(int num)
void SXLoaderConfig::Set(const char * sectionp, const char * key, const char * val)
{
String sections(sectionp);
String keys(key);
String vals(val);
ConfigString sections(sectionp);
ConfigString keys(key);
ConfigString vals(val);
if(!m_mSections.KeyExists(sections))
{
......@@ -470,11 +470,11 @@ void SXLoaderConfig::Set(const char * sectionp, const char * key, const char * v
int SXLoaderConfig::Save()
{
int terror = 0;
for(AssotiativeArray<String, section>::Iterator i = m_mSections.begin(); i; i++)
for(AssotiativeArray<ConfigString, section>::Iterator i = m_mSections.begin(); i; i++)
{
if(i.second->isModified)
{
for(AssotiativeArray<String, value>::Iterator j = i.second->mValues.begin(); j; j++)
for(AssotiativeArray<ConfigString, value>::Iterator j = i.second->mValues.begin(); j; j++)
{
if(j.second->isModified)
{
......@@ -498,7 +498,7 @@ int SXLoaderConfig::Save()
return 0;
}
int SXLoaderConfig::WriteFile(const String & name, String section, String key, const String & val)
int SXLoaderConfig::WriteFile(const ConfigString & name, ConfigString section, ConfigString key, const ConfigString & val)
{
//printf("W: %s\t[%s]: %s = %s\n", name.c_str(), section.c_str(), key.c_str(), val.c_str());
FILE * pF = fopen(name.c_str(), "rb");
......@@ -650,7 +650,7 @@ int SXLoaderConfig::WriteFile(const String & name, String section, String key, c
ErrorFile = name;
return -1;
}
fwrite((String("\n[") + section + "]\n" + key + " = " + val + "\n").c_str(), sizeof(char), section.length() + key.length() + val.length() + 8, pF);
fwrite((ConfigString("\n[") + section + "]\n" + key + " = " + val + "\n").c_str(), sizeof(char), section.length() + key.length() + val.length() + 8, pF);
fclose(pF);
return 0;
}
......@@ -663,7 +663,7 @@ int SXLoaderConfig::WriteFile(const String & name, String section, String key, c
ErrorFile = name;
return -1;
}
fwrite((String("[")+section+"]\n"+key+" = "+val+"\n").c_str(), sizeof(char), section.length() + key.length() + val.length() + 7, pF);
fwrite((ConfigString("[")+section+"]\n"+key+" = "+val+"\n").c_str(), sizeof(char), section.length() + key.length() + val.length() + 7, pF);
fclose(pF);
return 0;
}
......@@ -695,7 +695,7 @@ int SXLoaderConfig::GetKeyCount()
int SXLoaderConfig::GetKeyCount(const char* section)
{
String sections(section);
ConfigString sections(section);
if (m_mSections.KeyExists(sections))
{
......@@ -706,7 +706,7 @@ int SXLoaderConfig::GetKeyCount(const char* section)
bool SXLoaderConfig::SectionExists(const char * section)
{
String sections(section);
ConfigString sections(section);
if(m_mSections.KeyExists(sections))
return(true);
return(false);
......@@ -715,7 +715,7 @@ bool SXLoaderConfig::SectionExists(const char * section)
bool SXLoaderConfig::KeyExists(const char * section, const char * key)
{
String sections(section);
ConfigString sections(section);
if(m_mSections.KeyExists(sections))
return(m_mSections[sections].mValues.KeyExists(key));
return(false);
......@@ -741,12 +741,12 @@ void SXLoaderConfig::Clear()
BaseFile = "\0";
}
AssotiativeArray<String, SXLoaderConfig::section> * SXLoaderConfig::GetSections()
AssotiativeArray<ConfigString, SXLoaderConfig::section> * SXLoaderConfig::GetSections()
{
return(&m_mSections);
}
String SXLoaderConfig::GetIncludeName(int i)
ConfigString SXLoaderConfig::GetIncludeName(int i)
{
if(i >= 0 && i < m_vIncludes.size())
{
......
#include "SXLightPoint.h"
#include <mtllight/sxmtllight.h>
BEGIN_PROPTABLE(SXLightPoint)
DEFINE_FIELD_VECTOR(m_color, 0, "color", "Color", EDITOR_TEXTFIELD)
DEFINE_FIELD_FLOAT(m_power, 0, "power", "Power", EDITOR_TEXTFIELD)
DEFINE_FIELD_FLOAT(m_dist, 0, "dist", "Distance", EDITOR_TEXTFIELD)
DEFINE_FIELD_FLOAT(m_light_far, 0, "light_far", "Light far", EDITOR_TEXTFIELD)
DEFINE_FIELD_INT(m_typeshadow, 0, "type_shadow", "Type shadow", EDITOR_COMBOBOX)
COMBO_OPTION("None", "-1")
COMBO_OPTION("Static", "0")
COMBO_OPTION("Dynamic", "1")
EDITOR_COMBO_END()
END_PROPTABLE()
REGISTER_ENTITY(SXLightPoint, light_point);
SXLightPoint::SXLightPoint(EntityManager * pMgr) :
BaseClass(pMgr)
{
m_color = float3(1, 1, 1);
m_vPosition = float3_t(0, 0, 0);
m_power = 10;
m_dist = 10;
m_light_far = m_dist;
m_typeshadow = 1;
IDLight = SML_LigthsCreatePoint(&float3(0, 0, 0), m_power, m_dist, &m_color, false, true);
}
SXLightPoint::~SXLightPoint()
{
SML_LigthsDeleteLight(IDLight);
}
void SXLightPoint::OnSync()
{
BaseClass::OnSync();
static float3 vec;
SML_LigthsGetPos(IDLight, &vec, false);
if (vec.x != m_vPosition.x || vec.y != m_vPosition.y || vec.z != m_vPosition.z)
SML_LigthsSetPos(IDLight, &(float3)m_vPosition, false);
SML_LigthsSetColor(IDLight, &m_color);
SML_LigthsSetPower(IDLight, m_power);
if (SML_LigthsGetDist(IDLight) != m_dist)
{
SML_LigthsSetDist(IDLight, m_dist, true);
m_light_far = m_dist;
}
if (SML_LigthsGetShadowLocalFar(IDLight) != m_light_far)
SML_LigthsSetShadowLocalFar(IDLight, m_light_far);
if (SML_LigthsGetTypeShadowed(IDLight) != m_typeshadow)
SML_LigthsSetTypeShadowed(IDLight, (LightsTypeShadow)m_typeshadow);
}
#ifndef __sxlightpoint_h
#define __sxlightpoint_h
#include "SXpointEntity.h"
class SXLightPoint : public SXpointEntity
{
DECLARE_CLASS(SXLightPoint, SXpointEntity);
DECLARE_PROPTABLE();
public:
SXLightPoint(EntityManager * pMgr);
~SXLightPoint();
protected:
ID IDLight;
float3 m_color;
float m_power;
float m_dist;
float m_light_far;
int m_typeshadow;
void OnSync();
};
#endif
......@@ -1372,6 +1372,7 @@ void StaticGeom::GPURender(DWORD timeDelta, int sort_mtl, ID id_arr, ID exclude_
void StaticGeom::GPURenderSingly(DWORD timeDelta, ID id, ID id_tex)
{
STATIC_PRECOND_ARRCOMFOR_ERR_ID_MODEL(id, _VOID);
Segment** jarrsplits;
long jidbuff;
long jnumgroup;
......
#include <managed_render/editor/axes_helper.h>
namespace SXRenderFunc
{
namespace Delay
{
extern int64_t FreeVal;
};
};
AxesHelper::AxesHelper()
{
m_bIsDragging = m_bIsDraggingStart = m_bIsDraggingStop = false;
Scale = float3(1, 1, 1);
m_htype = HT_NONE;
}
AxesHelper::~AxesHelper()
......@@ -74,6 +83,9 @@ void AxesHelper::Render()
if (m_htype == HT_NONE)
return;
GData::DXDevice->SetTexture(0, 0);
SGCore_ShaderUnBind();
if(!m_bIsDragging)
{
dist = SMVector3Distance(Position, GData::ConstCurrCamPos) * 0.20f;
......@@ -547,6 +559,7 @@ void AxesHelper::OnMouseMove(int x, int y)
void AxesHelper::IntersectMove(const float3 & start, const float3 & dir)
{
SXRenderFunc::Delay::FreeVal = m_bIsDragging;
if (m_bIsDragging)
return;
......
......@@ -102,6 +102,29 @@ void Level::Load(const char* name)
}
SGCore_LoadTexLoadTextures();
if (config->KeyExists("level", "ambient_sounds"))
{
if (!Level::AmbientSounds)
Level::AmbientSounds = new LevelAmbientSounds();
else
Level::AmbientSounds->Clear();
String listsnds = config->GetKey("level", "ambient_sounds");
char tmpallpath[4096];
sprintf(tmpallpath, "%s", listsnds.c_str());
char* tmppath = strtok(tmpallpath, " ,|");
if (tmppath)
Level::AmbientSounds->Add(tmppath);