summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/game.cpp9
-rw-r--r--src/gui/updatewindow.cpp62
-rw-r--r--src/gui/updatewindow.h2
-rw-r--r--src/main.cpp3
4 files changed, 48 insertions, 28 deletions
diff --git a/src/game.cpp b/src/game.cpp
index 6013e4d5..48a4fd8d 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -752,6 +752,13 @@ int get_packet_length(short id)
void do_parse()
{
+
+
+/*switch 0079, actor connected
+ [10:44] Joseph_: 0078, actor_exists
+ [10:44] Munak: Heck, if Bill Clinton can do it surely *I* can!
+ [10:45] Joseph_: 007B, 01D8, 01D9, 01DA are the others*/
+
unsigned short id;
char *temp;
Being *being = NULL;
@@ -880,6 +887,8 @@ void do_parse()
being->y = get_y(RFIFOP(46));
being->direction = get_direction(RFIFOP(46));
being->weapon = RFIFOW(18);
+ if (being->isPlayer())
+ std::cout << RFIFOW(18) << std::endl;
add_node(being);
}
else
diff --git a/src/gui/updatewindow.cpp b/src/gui/updatewindow.cpp
index 7fc80dd7..044a1a5c 100644
--- a/src/gui/updatewindow.cpp
+++ b/src/gui/updatewindow.cpp
@@ -39,6 +39,7 @@ std::string updateHost = "themanaworld.org/files";
std::string currentFile = "news.txt";
bool downloadComplete = true;
int downloadStatus = UPDATE_NEWS;
+std::string basePath = "";
UpdaterWindow::UpdaterWindow()
: Window("Updating...")
@@ -120,9 +121,6 @@ void UpdaterWindow::action(const std::string& eventId)
else if (eventId == "play") {
state = LOGIN;
}
- else if (eventId == "ok") {
- state = LOGIN;
- }
}
void UpdaterWindow::loadNews()
@@ -141,6 +139,12 @@ void UpdaterWindow::loadNews()
setVisible(true);
}
+void UpdaterWindow::setText(std::string row) {
+ browserBox->addRow(row);
+ scrollArea->setVerticalScrollAmount(
+ scrollArea->getVerticalMaxScroll());
+}
+
int updateProgress(void *ptr,
double t, /* dltotal */
double d, /* dlnow */
@@ -177,8 +181,9 @@ int downloadThread(void *ptr)
{
// Download current file as a temp file
logger->log("Downloading: %s", url.c_str());
- // Download in the proper folder : ./data under win, /home/user/.tmw/data for unices
- std::string outFilename = config.getValue("homeDir", "") + "/data/download.temp";
+ // Download in the proper folder : ./data under win,
+ // /home/user/.tmw/data for unices
+ std::string outFilename = basePath + "/data/download.temp";
outfile = fopen(outFilename.c_str(), "wb");
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
curl_easy_setopt(curl, CURLOPT_WRITEDATA, outfile);
@@ -197,8 +202,8 @@ int downloadThread(void *ptr)
else {
// If the download was successful give the file the proper name
// else it will be deleted later
- std::string newName(config.getValue("homeDir", "") + "/data/");
- newName += currentFile.c_str();
+ std::string newName(basePath + "/data/" + currentFile.c_str());
+ logger->log("Renaming: %s -> %s", outFilename.c_str(), newName.c_str());
rename(outFilename.c_str(), newName.c_str());
}
}
@@ -215,9 +220,6 @@ void download()
logger->log("Unable to create thread");
downloadStatus = UPDATE_ERROR;
}
- else {
- logger->log("Starting download of %s", currentFile.c_str());
- }
}
void checkFile(std::ifstream &in) {
@@ -240,15 +242,16 @@ void checkFile(std::ifstream &in) {
void updateData()
{
+
updaterWindow = new UpdaterWindow();
state = UPDATE;
- std::string updateHost =
- config.getValue("updatehost", "themanaworld.org/files");
+ updateHost = config.getValue("updatehost", "themanaworld.org/files");
+ basePath = config.getValue("homeDir", ".");
// Try to download the updates list
download();
std::ifstream in;
-
+
while (state == UPDATE)
{
// Handle SDL events
@@ -273,13 +276,12 @@ void updateData()
switch (downloadStatus) {
case UPDATE_ERROR:
SDL_WaitThread(thread, NULL);
- new OkDialog(
- "Error",
- "The update process is incomplete.\n"
- "It is strongly recommended that you try again later",
- updaterWindow);
- logger->log("Error during the update process");
- downloadStatus = UPDATE_IDLE;
+ //cancellare tutto, rimettere browser box protected, creare metodi per aggiungere linee e cancellare tutto
+ updaterWindow->setText("");
+ updaterWindow->setText("##1 The update process is incomplete.");
+ updaterWindow->setText("##1 It is strongly recommended that");
+ updaterWindow->setText("##1 you try again later");
+ downloadStatus = UPDATE_COMPLETE;
break;
case UPDATE_NEWS:
// If not already downloading another file
@@ -300,7 +302,7 @@ void updateData()
if (!in.is_open())
{
// Try to open resources.txt
- in.open(TMW_DATADIR "data/resources.txt");
+ in.open((basePath + "/data/resources.txt").c_str(), std::ifstream::in);
if (!in.is_open())
{
logger->log("Unable to open resources.txt");
@@ -312,14 +314,20 @@ void updateData()
}
else {
SDL_WaitThread(thread, NULL);
- if (!in.eof())
+ if (in.is_open() && !in.eof())
{
// Download each update
std::string line("");
getline(in, line);
- // TODO: it should check if file already exists
currentFile = line;
- download();
+ std::ifstream temp((basePath + "/data" + line).c_str(), std::ifstream::in);
+ if (temp.is_open()) {
+ temp.close();
+ download();
+ }
+ else {
+ logger->log("%s is already here", line.c_str());
+ }
}
else {
// Download of updates completed
@@ -345,9 +353,9 @@ void updateData()
in.close();
// Remove downloaded files
- remove(TMW_DATADIR "data/news.txt");
- remove(TMW_DATADIR "data/resources.txt");
- remove(TMW_DATADIR "data/download.temp");
+ remove((basePath + "/data/news.txt").c_str());
+ remove((basePath + "/data/resources.txt").c_str());
+ remove((basePath + "/data/download.temp").c_str());
delete updaterWindow;
}
diff --git a/src/gui/updatewindow.h b/src/gui/updatewindow.h
index f5f7f747..6c807611 100644
--- a/src/gui/updatewindow.h
+++ b/src/gui/updatewindow.h
@@ -92,6 +92,8 @@ class UpdaterWindow : public Window, public gcn::ActionListener
void draw(gcn::Graphics *);
+ void setText(std:: string row);
+
int updateState;
};
diff --git a/src/main.cpp b/src/main.cpp
index 1991aa5a..2efcc519 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -139,7 +139,7 @@ void init_engine()
std::string homeDir = "";
#ifndef __USE_UNIX98
// In Windows and other systems we currently store data next to executable.
- homeDir = TMW_DATADIR;
+ homeDir = ".";
#else
// But, in UNIX we store data in ~/.tmw/
passwd *pass = getpwuid(geteuid());
@@ -191,6 +191,7 @@ void init_engine()
config.setValue("updatehost", "http://themanaworld.org/files");
config.setValue("customcursor", 1);
config.setValue("homeDir", homeDir);
+ config.setValue("joytolerance", 10);
// Checking if the configuration file exists... otherwise creates it with
// default options !