summaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorAlexander Baldeck <alexander@archlinux.org>2004-12-14 11:40:55 +0000
committerAlexander Baldeck <alexander@archlinux.org>2004-12-14 11:40:55 +0000
commit900d3ce7ea8e64e6d0bac360d86fef921f37e43b (patch)
tree760cb9ca93c2ace4fa1e9ae646016de0402fecea /src/main.cpp
parent43044d81cb500edc5d142ab9211a81c609d5f8b9 (diff)
downloadmana-900d3ce7ea8e64e6d0bac360d86fef921f37e43b.tar.gz
mana-900d3ce7ea8e64e6d0bac360d86fef921f37e43b.tar.bz2
mana-900d3ce7ea8e64e6d0bac360d86fef921f37e43b.tar.xz
mana-900d3ce7ea8e64e6d0bac360d86fef921f37e43b.zip
*** empty log message ***
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp108
1 files changed, 49 insertions, 59 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 907c1e39..67a307a3 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -29,7 +29,7 @@
#include <iostream>
-// Part of the patch - bertram
+// Part of the patch - bertram
#ifdef __USE_UNIX98
#include <sys/stat.h>
#include <pwd.h>
@@ -66,7 +66,7 @@ LanguageMap languageMap[] = {
{ 0x0424, "SK" },
{ 0x0809, "UK" },
{ 0x0409, "US" },
- { 0, NULL }
+ { 0, NULL }
};
/* Account infos */
@@ -124,99 +124,89 @@ void init_engine() {
allegro_init();
init_log();
- set_close_button_callback(request_exit); // we should not use set_window_close_hook() since it's deprecated and might be gone in the future /-kth5
-
+ set_close_button_callback(request_exit);
+
// A little sample of code that will add (or not) the home user directory to read the tmw.ini file in, if we are under Linux. - Bertram
-
+
// This has the goal to have each user is own ini.file under linux. And I do this because i'm expecting to make packages of manaworld for linux, so the tmw.ini will be copied at the right place before the first execution of the application...
-
+
char *dir = new char[400];
strcpy(dir, "");
-
+
#ifndef __USE_UNIX98
- // WIN32 and else...
- printf("Windows and else version\n");
- strcpy(dir, "tmw.ini");
+ // WIN32 and else...
+ strcpy(dir, "tmw.ini");
#endif
-
- #ifdef __USE_UNIX98
- printf("Linux Version\n");
- // Linux !
- char *userHome;
- char *name = getlogin();
+ #ifdef __USE_UNIX98
+ // Linux !
+ char *userHome;
+ char *name = getlogin();
+ passwd *pass;
- passwd *pass;
+ if (name != NULL)
+ pass = getpwnam(name);
+ else
+ pass = getpwuid(geteuid());
- if (name != NULL)
- pass = getpwnam(name);
- else
- pass = getpwuid(geteuid());
+ if (pass == NULL)
+ {
+ printf("Couldn't determine the user home directory. Exitting.\n");
+ exit(1);
+ }
- if (pass == NULL)
- {
- printf("Couldn't determine the user home directory. Exitting.\n");
- exit(1);
- }
+ userHome = pass->pw_dir;
- userHome = pass->pw_dir;
-
- // Checking if homeuser/.manaworld folder exists.
- sprintf(dir, "%s/.manaworld", userHome);
- if ((mkdir(dir, S_IRWXU|S_IRWXG|S_IROTH|S_IXOTH) != 0) && (errno != EEXIST))
- {
- printf("%s can't be made... And doesn't exist ! Exitting ...", dir);
- exit(1);
- }
- sprintf(dir, "%s/.manaworld/tmw.ini", userHome);
- //printf("file is : %s\n", dir);
-
- // You don't have to delete name and userHome, since they both point to datas that mustn't be destroyed while LINUX is running.
-
+ // Checking if homeuser/.manaworld folder exists.
+ sprintf(dir, "%s/.manaworld", userHome);
+ if ((mkdir(dir, S_IRWXU|S_IRWXG|S_IROTH|S_IXOTH) != 0) && (errno != EEXIST))
+ {
+ printf("%s can't be made... And doesn't exist ! Exitting ...", dir);
+ exit(1);
+ }
+ sprintf(dir, "%s/.manaworld/tmw.ini", userHome);
#endif
-
+
// Checking if the tmw.ini file exists... otherwise creates it with default options !
FILE *tmwFile = 0;
tmwFile = fopen(dir, "r");
-
+
// If we can't read it, it doesn't exist !
if ( tmwFile == NULL )
{
// We reopen the file in write mode and we create it
printf("No file : %s\n, Creating Default Options...\n", dir);
tmwFile = fopen(dir, "wt");
- if ( tmwFile == NULL )
- {
+ if ( tmwFile == NULL ) {
printf("Can't create %s file. Using Defaults.\n", dir);
}
else
{
// tmw.ini creation
fprintf(tmwFile, "[system]\nsystem =\nkeyboard = en\nlanguage = \ncore_version = 0.0.8\n\n");
-
fprintf(tmwFile, "[server]\nhost = animesites.de\nport = 6901\n\n");
fprintf(tmwFile, "[settings]\n; = Screen mode:\n; = 1 Fullscreen\n; = 2 Windowed\nscreen = 2\n");
fprintf(tmwFile, "; = Sound:\n; = 1 enabled\n; = 0 disabled\nsound = 0\n");
-
-
-
+
+
+
char * chatlogFilename = new char [400];
#ifdef __USE_UNIX98
- sprintf(chatlogFilename, "%s/.manaworld/chatlog.txt", userHome);
+ sprintf(chatlogFilename, "%s/.manaworld/chatlog.txt", userHome);
#else
- strcpy(chatlogFilename, "chatlog.txt");
+ strcpy(chatlogFilename, "chatlog.txt");
#endif
- fprintf(tmwFile, "; = Chat logfile location:\nchatlog = %s\n", chatlogFilename);
+ fprintf(tmwFile, "; = Chat logfile location:\nchatlog = %s\n", chatlogFilename);
delete chatlogFilename; chatlogFilename = 0;
-
+
fprintf(tmwFile, "; = Display strecth mode:\n; = 0 Disabled (Test only)\n; = 1 Normal\n; = 2 SuperEagle\n");
fprintf(tmwFile, "stretch = 1\n\n");
fprintf(tmwFile, "[login]\nremember = 1\nusername = Player\n");
-
+
fclose(tmwFile);
}
}
-
+
set_config_file(dir);
#ifdef WIN32
if(code) {
@@ -225,11 +215,11 @@ void init_engine() {
#endif
delete dir; dir = 0;
-
-
-
+
+
+
// End of portion of code revised... Bertram
-
+
// set_config_file("tmw.ini");
#ifdef MACOSX
set_color_depth(32);
@@ -265,7 +255,7 @@ void init_engine() {
weaponset = load_datafile("./data/graphic/weapon.dat");
if(weaponset==NULL)
error("Unable to load weaponset datafile");
-
+
init_gui(buffer, "./data/Skin/aqua.skin");
state = LOGIN;
}