summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBen Longbons <b.r.longbons@gmail.com>2013-10-13 14:07:25 -0700
committerBen Longbons <b.r.longbons@gmail.com>2013-10-15 19:46:00 -0700
commit60d9e17f3719eca2eb4531f9f01976b1e26c411b (patch)
treea0e5ba308526a6adb906c3bae1de239ccf8acafb /src
parent962552f17274dc066d17ab3d6c9495d77d681314 (diff)
downloadtmwa-60d9e17f3719eca2eb4531f9f01976b1e26c411b.tar.gz
tmwa-60d9e17f3719eca2eb4531f9f01976b1e26c411b.tar.bz2
tmwa-60d9e17f3719eca2eb4531f9f01976b1e26c411b.tar.xz
tmwa-60d9e17f3719eca2eb4531f9f01976b1e26c411b.zip
Use config for internal server userid/passwd instead of accounts.txt
This requires updated config files in the data repo.
Diffstat (limited to 'src')
-rw-r--r--src/common/mmo.hpp8
-rw-r--r--src/login/login.cpp42
-rw-r--r--src/map/itemdb.cpp2
-rw-r--r--src/map/pc.cpp4
4 files changed, 29 insertions, 27 deletions
diff --git a/src/common/mmo.hpp b/src/common/mmo.hpp
index 6dff03a..cfc7b78 100644
--- a/src/common/mmo.hpp
+++ b/src/common/mmo.hpp
@@ -271,8 +271,8 @@ enum class SEX : uint8_t
{
FEMALE = 0,
MALE = 1,
- SERVER = 2,
- ERROR,
+ // For items. This is also used as error, sometime.
+ NEUTRAL = 2,
};
inline
char sex_to_char(SEX sex)
@@ -281,7 +281,6 @@ char sex_to_char(SEX sex)
{
case SEX::FEMALE: return 'F';
case SEX::MALE: return 'M';
- case SEX::SERVER: return 'S';
default: return '\0';
}
}
@@ -292,8 +291,7 @@ SEX sex_from_char(char c)
{
case 'F': return SEX::FEMALE;
case 'M': return SEX::MALE;
- case 'S': return SEX::SERVER;
- default: return SEX::ERROR;
+ default: return SEX::NEUTRAL;
}
}
diff --git a/src/login/login.cpp b/src/login/login.cpp
index 3a76c00..1460264 100644
--- a/src/login/login.cpp
+++ b/src/login/login.cpp
@@ -83,6 +83,10 @@ IP4Mask lan_subnet;
static
FString update_host;
static
+AccountName userid;
+static
+AccountPass passwd;
+static
ServerName main_server;
static
@@ -507,7 +511,7 @@ bool extract(XString line, AuthData *ad)
if (sex.size() != 1)
return false;
ad->sex = sex_from_char(sex.front());
- if (ad->sex == SEX::ERROR)
+ if (ad->sex == SEX::NEUTRAL)
return false;
if (!e_mail_check(ad->email))
@@ -532,7 +536,6 @@ static
int mmo_auth_init(void)
{
int GM_count = 0;
- int server_count = 0;
std::ifstream in(account_filename.c_str());
if (!in.is_open())
@@ -569,15 +572,13 @@ int mmo_auth_init(void)
if (isGM(ad.account_id) > 0)
GM_count++;
- if (ad.sex == SEX::SERVER)
- server_count++;
if (ad.account_id >= account_id_count)
account_id_count = ad.account_id + 1;
}
- FString str = STRPRINTF("%s has %zu accounts (%d GMs, %d servers)\n",
- account_filename, auth_data.size(), GM_count, server_count);
+ FString str = STRPRINTF("%s has %zu accounts (%d GMs)\n",
+ account_filename, auth_data.size(), GM_count);
PRINTF("%s: %s\n", __PRETTY_FUNCTION__, str);
LOGIN_LOG("%s\n", line);
@@ -1368,11 +1369,6 @@ void parse_fromchar(int fd)
{
if (ad.account_id == acc)
{
- if (ad.sex == SEX::SERVER)
- LOGIN_LOG("Char-server '%s': Error of sex change - Server account (suggested account: %d, actual sex %d (Server), ip: %s).\n",
- server[id].name, acc,
- ad.sex, ip);
- else
{
unsigned char buf[16];
SEX sex;
@@ -2955,15 +2951,14 @@ void parse_login(int fd)
ServerName server_name = stringish<ServerName>(RFIFO_STRING<20>(fd, 60).to_print());
LOGIN_LOG("Connection request of the char-server '%s' @ %s:%d (ip: %s)\n",
server_name, RFIFOIP(fd, 54), RFIFOW(fd, 58), ip);
- result = mmo_auth(&account, fd);
-
- if (result == -1 && account.sex == SEX::SERVER)
+ if (account.userid == userid && account.passwd == passwd)
{
// If this is the main server, and we don't already have a main server
if (server_fd[0] <= 0
&& server_name == main_server)
{
account.account_id = 0;
+ goto x2710_okay;
}
else
{
@@ -2973,16 +2968,15 @@ void parse_login(int fd)
if (server_fd[i] <= 0)
{
account.account_id = i;
- break;
+ goto x2710_okay;
}
}
}
}
+ goto x2710_refused;
- if (result == -1 && account.sex == SEX::SERVER
- && account.account_id < MAX_SERVERS
- && server_fd[account.account_id] == -1)
{
+ x2710_okay:
LOGIN_LOG("Connection of the char-server '%s' accepted (account: %s, pass: %s, ip: %s)\n",
server_name, account.userid,
account.passwd, ip);
@@ -3016,9 +3010,10 @@ void parse_login(int fd)
}
WFIFOW(fd, 2) = len;
WFIFOSET(fd, len);
+ goto x2710_done;
}
- else
{
+ x2710_refused:
LOGIN_LOG("Connexion of the char-server '%s' REFUSED (account: %s, pass: %s, ip: %s)\n",
server_name, account.userid,
account.passwd, ip);
@@ -3027,6 +3022,7 @@ void parse_login(int fd)
WFIFOSET(fd, 3);
}
}
+ x2710_done:
RFIFOSKIP(fd, 86);
return;
@@ -3469,6 +3465,14 @@ int login_config_read(ZString cfgName)
{
main_server = stringish<ServerName>(w2);
}
+ else if (w1 == "userid")
+ {
+ userid = stringish<AccountName>(w2);
+ }
+ else if (w1 == "passwd")
+ {
+ passwd = stringish<AccountPass>(w2);
+ }
else
{
FString w1z = w1;
diff --git a/src/map/itemdb.cpp b/src/map/itemdb.cpp
index c0d54c9..a8d8b55 100644
--- a/src/map/itemdb.cpp
+++ b/src/map/itemdb.cpp
@@ -84,7 +84,7 @@ struct item_data *itemdb_search(int nameid)
id->value_buy = 10;
id->value_sell = id->value_buy / 2;
id->weight = 10;
- id->sex = SEX::SERVER;
+ id->sex = SEX::NEUTRAL;
id->elv = 0;
if (nameid > 500 && nameid < 600)
diff --git a/src/map/pc.cpp b/src/map/pc.cpp
index 8750910..4600aeb 100644
--- a/src/map/pc.cpp
+++ b/src/map/pc.cpp
@@ -592,7 +592,7 @@ int pc_isequip(dumb_ptr<map_session_data> sd, int n)
if (item == NULL)
return 0;
- if (item->sex != SEX::SERVER && sd->status.sex != item->sex)
+ if (item->sex != SEX::NEUTRAL && sd->status.sex != item->sex)
return 0;
if (item->elv > 0 && sd->status.base_level < item->elv)
return 0;
@@ -2228,7 +2228,7 @@ int pc_isUseitem(dumb_ptr<map_session_data> sd, int n)
if (itemdb_type(nameid) != ItemType::USE)
return 0;
- if (item->sex != SEX::SERVER && sd->status.sex != item->sex)
+ if (item->sex != SEX::NEUTRAL && sd->status.sex != item->sex)
return 0;
if (item->elv > 0 && sd->status.base_level < item->elv)
return 0;