summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjörn Steinbrink <B.Steinbrink@gmx.de>2005-08-25 20:03:31 +0000
committerBjörn Steinbrink <B.Steinbrink@gmx.de>2005-08-25 20:03:31 +0000
commit9ba130f4628d8e52ebd50b810e761a81f69c0c4a (patch)
tree7493736309632e753f4f3aba1d001f14f9ad765f
parent7cd9c0d02d148cdbacbca6624d8749a344ddbfe0 (diff)
downloadmana-9ba130f4628d8e52ebd50b810e761a81f69c0c4a.tar.gz
mana-9ba130f4628d8e52ebd50b810e761a81f69c0c4a.tar.bz2
mana-9ba130f4628d8e52ebd50b810e761a81f69c0c4a.tar.xz
mana-9ba130f4628d8e52ebd50b810e761a81f69c0c4a.zip
Move extern declaration of the floor item list. Lower indentation level.
-rw-r--r--ChangeLog7
-rw-r--r--src/engine.cpp2
-rwxr-xr-xsrc/floor_item.cpp26
-rwxr-xr-xsrc/floor_item.h4
-rw-r--r--src/log.cpp55
5 files changed, 53 insertions, 41 deletions
diff --git a/ChangeLog b/ChangeLog
index 55211aeb..d89d4281 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -8,7 +8,12 @@
2005-08-25 Björn Steinbrink <B.Steinbrink@gmx.de>
- * src/openglgraphics.cpp, src/openglgraphics.h: Reduce code duplication.
+ * src/engine.cpp, src/floor_item.cpp, src/floor_item.h: Move the
+ extern declaration for the floor item list into engine.cpp as it's
+ only used there.
+ * src/log.cpp: Lower indentation level.
+ * src/openglgraphics.cpp, src/openglgraphics.h: Reduce code
+ duplication.
* src/configuration.cpp: Fix compilation errors.
* src/graphics.cpp, src/openglgraphics.cpp, src/gui/button.cpp,
src/gui/checkbox.cpp, src/gui/equipmentwindow.cpp,
diff --git a/src/engine.cpp b/src/engine.cpp
index 72d90a61..50e271de 100644
--- a/src/engine.cpp
+++ b/src/engine.cpp
@@ -23,6 +23,7 @@
#include "engine.h"
+#include <list>
#include <sstream>
#include <guichan/imagefont.hpp>
@@ -55,6 +56,7 @@ extern Being *autoTarget;
extern Graphics *graphics;
extern Minimap *minimap;
extern Spriteset *hairset, *playerset;
+extern std::list<FloorItem*> floorItems;
char itemCurrenyQ[10] = "0";
int camera_x, camera_y;
diff --git a/src/floor_item.cpp b/src/floor_item.cpp
index 486720e3..d7c597fe 100755
--- a/src/floor_item.cpp
+++ b/src/floor_item.cpp
@@ -23,9 +23,12 @@
#include "floor_item.h"
+#include <list>
+
std::list<FloorItem*> floorItems;
-void empty_floor_items() {
+void empty_floor_items()
+{
std::list<FloorItem *>::iterator i;
for (i = floorItems.begin(); i != floorItems.end(); i++) {
delete (*i);
@@ -33,11 +36,13 @@ void empty_floor_items() {
floorItems.clear();
}
-void add_floor_item(FloorItem *floorItem) {
+void add_floor_item(FloorItem *floorItem)
+{
floorItems.push_back(floorItem);
}
-void remove_floor_item(unsigned int int_id) {
+void remove_floor_item(unsigned int int_id)
+{
std::list<FloorItem *>::iterator i;
for (i = floorItems.begin(); i != floorItems.end(); i++) {
if ((*i)->int_id == int_id) {
@@ -48,7 +53,8 @@ void remove_floor_item(unsigned int int_id) {
}
}
-unsigned int find_floor_item_by_cor(unsigned short x, unsigned short y) {
+unsigned int find_floor_item_by_cor(unsigned short x, unsigned short y)
+{
std::list<FloorItem *>::iterator i;
for (i = floorItems.begin(); i != floorItems.end(); i++) {
FloorItem *floorItem = (*i);
@@ -60,7 +66,8 @@ unsigned int find_floor_item_by_cor(unsigned short x, unsigned short y) {
return 0;
}
-FloorItem *find_floor_item_by_id(unsigned int int_id) {
+FloorItem *find_floor_item_by_id(unsigned int int_id)
+{
std::list<FloorItem*>::iterator i;
for (i = floorItems.begin(); i != floorItems.end(); i++) {
FloorItem *floorItem = (*i);
@@ -71,10 +78,11 @@ FloorItem *find_floor_item_by_id(unsigned int int_id) {
return NULL;
}
-FloorItem::FloorItem() {
- id = 0; int_id = 0;
- x = 0; y = 0;
+FloorItem::FloorItem():
+ id(0), int_id(0), x(0), y(0)
+{
}
-FloorItem::~FloorItem() {
+FloorItem::~FloorItem()
+{
}
diff --git a/src/floor_item.h b/src/floor_item.h
index 80be9c78..2c31525e 100755
--- a/src/floor_item.h
+++ b/src/floor_item.h
@@ -24,8 +24,6 @@
#ifndef _TMW_FLOORITEM_H
#define _TMW_FLOORITEM_H
-#include <list>
-
class FloorItem {
private:
public:
@@ -59,6 +57,4 @@ void remove_floor_item(unsigned int int_id);
/** Find a Item id based on its coordinates */
unsigned int find_floor_item_by_cor(unsigned short x, unsigned short y);
-extern std::list<FloorItem*> floorItems;
-
#endif
diff --git a/src/log.cpp b/src/log.cpp
index 3222c856..f24461cb 100644
--- a/src/log.cpp
+++ b/src/log.cpp
@@ -50,38 +50,39 @@ void Logger::setLogFile(const std::string &logFilename)
void Logger::log(const char *log_text, ...)
{
- if (logFile.is_open())
- {
- char* buf = new char[1024];
- va_list ap;
- time_t t;
+ if (!logFile.is_open()) {
+ return;
+ }
- // Use a temporary buffer to fill in the variables
- va_start(ap, log_text);
- vsprintf(buf, log_text, ap);
- va_end(ap);
+ char* buf = new char[1024];
+ va_list ap;
+ time_t t;
- // Get the current system time
- time(&t);
+ // Use a temporary buffer to fill in the variables
+ va_start(ap, log_text);
+ vsprintf(buf, log_text, ap);
+ va_end(ap);
- // Print the log entry
- std::stringstream timeStr;
- timeStr << "[";
- timeStr << ((((t / 60) / 60) % 24 < 10) ? "0" : "");
- timeStr << (int)(((t / 60) / 60) % 24);
- timeStr << ":";
- timeStr << (((t / 60) % 60 < 10) ? "0" : "");
- timeStr << (int)((t / 60) % 60);
- timeStr << ":";
- timeStr << ((t % 60 < 10) ? "0" : "");
- timeStr << (int)(t % 60);
- timeStr << "] ";
+ // Get the current system time
+ time(&t);
- logFile << timeStr.str() << buf << std::endl;
+ // Print the log entry
+ std::stringstream timeStr;
+ timeStr << "[";
+ timeStr << ((((t / 60) / 60) % 24 < 10) ? "0" : "");
+ timeStr << (int)(((t / 60) / 60) % 24);
+ timeStr << ":";
+ timeStr << (((t / 60) % 60 < 10) ? "0" : "");
+ timeStr << (int)((t / 60) % 60);
+ timeStr << ":";
+ timeStr << ((t % 60 < 10) ? "0" : "");
+ timeStr << (int)(t % 60);
+ timeStr << "] ";
- // Delete temporary buffer
- delete[] buf;
- }
+ logFile << timeStr.str() << buf << std::endl;
+
+ // Delete temporary buffer
+ delete[] buf;
}
void Logger::error(const std::string &error_text)