Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-05-31 11:43:46 +0000
committerStijn Buys <ingar@osirion.org>2008-05-31 11:43:46 +0000
commit2a41efa0d43b573e1c8851086268b8a64d51c511 (patch)
tree1727c8aeb8b540ee4990bd92c0e8158a409b9397
parent4b527153ccf2a2830e38038ce4cf06ccc764d310 (diff)
fixes zlib compression, infi file parser updates
-rw-r--r--osirion.kdevelop.pcsbin731790 -> 732561 bytes
-rw-r--r--osirion.kdevses27
-rw-r--r--src/auxiliary/functions.cc10
-rw-r--r--src/auxiliary/functions.h3
-rw-r--r--src/core/netclient.cc10
-rw-r--r--src/core/netconnection.cc14
-rw-r--r--src/core/netconnection.h2
-rw-r--r--src/filesystem/inifile.cc17
-rw-r--r--src/render/draw.cc3
9 files changed, 49 insertions, 37 deletions
diff --git a/osirion.kdevelop.pcs b/osirion.kdevelop.pcs
index 382fb52..7ba66d6 100644
--- a/osirion.kdevelop.pcs
+++ b/osirion.kdevelop.pcs
Binary files differ
diff --git a/osirion.kdevses b/osirion.kdevses
index d364171..527c193 100644
--- a/osirion.kdevses
+++ b/osirion.kdevses
@@ -1,31 +1,16 @@
<?xml version = '1.0' encoding = 'UTF-8'?>
<!DOCTYPE KDevPrjSession>
<KDevPrjSession>
- <DocsAndViews NumberOfDocuments="8" >
- <Doc0 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/core/netconnection.cc" >
- <View0 Encoding="" line="192" Type="Source" />
+ <DocsAndViews NumberOfDocuments="3" >
+ <Doc0 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/core/netserver.cc" >
+ <View0 Encoding="" line="0" Type="Source" />
</Doc0>
<Doc1 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/core/netclient.cc" >
- <View0 Encoding="" line="139" Type="Source" />
+ <View0 Encoding="" line="152" Type="Source" />
</Doc1>
- <Doc2 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/core/netconnection.h" >
- <View0 Encoding="" line="109" Type="Source" />
+ <Doc2 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/core/netconnection.cc" >
+ <View0 Encoding="" line="175" Type="Source" />
</Doc2>
- <Doc3 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/core/gameserver.cc" >
- <View0 Encoding="" line="0" Type="Source" />
- </Doc3>
- <Doc4 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/server/server.cc" >
- <View0 Encoding="" line="109" Type="Source" />
- </Doc4>
- <Doc5 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/client/view.cc" >
- <View0 Encoding="" line="156" Type="Source" />
- </Doc5>
- <Doc6 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/model/mapfile.cc" >
- <View0 Encoding="" line="410" Type="Source" />
- </Doc6>
- <Doc7 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/model/map.cc" >
- <View0 Encoding="" line="0" Type="Source" />
- </Doc7>
</DocsAndViews>
<pluginList>
<kdevdebugger>
diff --git a/src/auxiliary/functions.cc b/src/auxiliary/functions.cc
index e9861ac..5edff56 100644
--- a/src/auxiliary/functions.cc
+++ b/src/auxiliary/functions.cc
@@ -122,4 +122,14 @@ const std::string lowercase(const std::string &text)
return t;
}
+void trim(std::string &text)
+{
+ while (text.size() && text[0] == ' ') {
+ text.erase(0, 1);
+ }
+ while (text.size() && text[text.size()-1] == ' ') {
+ text.erase(text.size()-1, 1);
+ }
+}
+
}
diff --git a/src/auxiliary/functions.h b/src/auxiliary/functions.h
index 90eb2ed..ceab0de 100644
--- a/src/auxiliary/functions.h
+++ b/src/auxiliary/functions.h
@@ -49,6 +49,9 @@ const std::string text_strip(const std::string &text);
/// return text, stripped of color codes and converted to lowercase
const std::string text_strip_lowercase(const std::string &text);
+/// trim leading ad trailing spaces from a string
+void trim(std::string &text);
+
}
#endif // __INCLUDED_AUX_FUNCTIONS_H__
diff --git a/src/core/netclient.cc b/src/core/netclient.cc
index 5254b23..310a64c 100644
--- a/src/core/netclient.cc
+++ b/src/core/netclient.cc
@@ -130,10 +130,10 @@ void NetClient::transmit(int serverfd)
return;
}
- char zbuf[BLOCKSIZE];
+ unsigned char zbuf[BLOCKSIZE];
const char *data = 0;
- unsigned long compressed_size = BLOCKSIZE - 5;
- unsigned long uncompressed_size = sendq.size();
+ uLong compressed_size = (uLong) BLOCKSIZE - 5;
+ uLong uncompressed_size = (uLong) sendq.size();
size_t total_size = 0;
memset(zbuf,0, sizeof(zbuf));
@@ -145,8 +145,8 @@ void NetClient::transmit(int serverfd)
if ((status == Z_OK) && (compressed_size + 4 < sendq.size())) {
// add a header to the compress packet
- data = zbuf;
- total_size = compressed_size + 4;
+ data = (char *) zbuf;
+ total_size = (size_t) (compressed_size + 4);
zbuf[0] = '\xff';
zbuf[1] = '\xff';
zbuf[2] = compressed_size % 256;
diff --git a/src/core/netconnection.cc b/src/core/netconnection.cc
index a0a0497..fc2e5d0 100644
--- a/src/core/netconnection.cc
+++ b/src/core/netconnection.cc
@@ -164,13 +164,13 @@ void NetConnection::receive()
zrecvbuf[received_compressed_size] = *c;
received_compressed_size++;
- if (received_compressed_size == (size_t) compressed_size) {
+ if (compressed_size == received_compressed_size) {
// uncompress
- char zunbuf[BLOCKSIZE];
+ char zunbuf[BLOCKSIZE*2];
memset(zunbuf, 0, sizeof(zunbuf));
- unsigned long zunbuf_size = BLOCKSIZE - 1;
+ uLong zunbuf_size = (uLong) BLOCKSIZE*2 - 1;
- int status = uncompress((Bytef *) zunbuf, &zunbuf_size, (Bytef *) zrecvbuf, compressed_size);
+ int status = uncompress((Bytef *) zunbuf, &zunbuf_size, (Bytef *) zrecvbuf, (uLong) compressed_size);
if (status != Z_OK) {
con_warn << "zlib error " << status << " uncompressing incoming datablock!\n";
@@ -203,10 +203,14 @@ void NetConnection::receive()
receive_compressed = true;
received_compressed_size = 0;
- compressed_size = *(c+2) + (*(c+3) << 8);
+ compressed_size = (uLong) (*(unsigned char *)(c+2) + (*(unsigned char *)(c+3) << 8));
c += 3;
bytes_received -= 3;
memset(zrecvbuf, 0, sizeof(zrecvbuf));
+ if (compressed_size > BLOCKSIZE) {
+ con_warn << "Incoming compressed datablock exceeds " << BLOCKSIZE << " bytes!\n";
+ receive_compressed = false;
+ }
} else if (( *c == '\n') || (*c == '\r')) {
if (messageblock.size()) {
diff --git a/src/core/netconnection.h b/src/core/netconnection.h
index d3c6cf7..ddc70f0 100644
--- a/src/core/netconnection.h
+++ b/src/core/netconnection.h
@@ -107,7 +107,7 @@ private:
bool receive_compressed;
size_t received_compressed_size;
- unsigned long compressed_size;
+ size_t compressed_size;
char zrecvbuf[BLOCKSIZE];
};
diff --git a/src/filesystem/inifile.cc b/src/filesystem/inifile.cc
index 337cf45..0cc690f 100644
--- a/src/filesystem/inifile.cc
+++ b/src/filesystem/inifile.cc
@@ -4,6 +4,7 @@
the terms of the GNU General Public License version 2
*/
+#include "auxiliary/functions.h"
#include "math/mathlib.h"
#include "filesystem/filesystem.h"
#include "filesystem/inifile.h"
@@ -83,21 +84,27 @@ bool IniFile::getline() {
if (s.size() > 2 && s[0] == '[' && s[s.size()-1] == ']') {
// condebug << "Inifile got section header " << s << std::endl;
section_current = s.substr(1, s.size()-2);
+
+ aux::trim(section_current);
+ aux::to_lowercase(section_current);
+
last_read_was_section = true;
return true;
} else {
// key=value pair
size_t found = s.find('=');
- if (found != std::string::npos) {
- // make lowercase
+ if (found != std::string::npos && found > 0) {
+ // make lowercase and strip spaces
key_current = s.substr(0, found);
- while (key_current.size() && key_current[key_current.size()-1] == ' ')
- key_current.erase(key_current.size()-1, 1);
+ aux::trim(key_current);
+ aux::to_lowercase(key_current);
if (key_current.size()) {
value_current = s.substr(found+1, s.size() - found - 1);
- last_read_was_key = true;
+ aux::trim (value_current);
+ last_read_was_key = true;
+ //con_debug << "IniFile got " << key_current << "=" << value_current << std::endl;
return true;
}
diff --git a/src/render/draw.cc b/src/render/draw.cc
index 351b1a6..cb16b89 100644
--- a/src/render/draw.cc
+++ b/src/render/draw.cc
@@ -230,6 +230,9 @@ void pass_prepare(float seconds)
if (!entity->model()) {
entity->entity_modelname.clear();
} else {
+ // set entity radius to model radius
+ entity->entity_radius = entity->entity_model->radius();
+
for (std::list<model::Light *>::iterator lit = entity->model()->model_light.begin(); lit != entity->model()->model_light.end(); lit++) {
model::Light *light = (*lit);