Skip to content

Commit 98f6bbb

Browse files
Added serverkey to config. Added sv_areainfo command.
1 parent 934e316 commit 98f6bbb

9 files changed

Lines changed: 72 additions & 3 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ v3.*
1010
*.log
1111
*.o
1212
*.d
13+
.serverkey
1314
accman/var

docs/quests.md

100755100644
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,23 @@ Feels easier then Creepers at first. Larger groups with evasive mages can be cha
1818

1919

2020
**5000 EXP, 27% of level 16.**
21+
22+
## Smuggler Book (Below Aston 2, Imp. Leader)
23+
24+
Went right past the book and cleared the section. Found the book on the way back.
25+
26+
** 1000 EXP, 6.7% of level 15.**
27+
28+
## Contraband (Below Aston 2, Imp. Leader)
29+
30+
Quest items as random drops. Not sure if this is a good idea. I got all but one twice on a single run, so it might be fine.
31+
32+
**4x1000 EXP, 27% of level 15.**
33+
34+
## Smuggler Leader (Below Aston 2, Imp. Leader)
35+
36+
Guild leader was a wimp, continuing the tradition.
37+
38+
_The kill does not count unless you received the quest already. Considering that many players will just clear the area right away this might need fixing.
39+
_
40+
**2000 EXP, 13% of level 15.**

src/client.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ union ceffect {
261261
#define SV_GOLD 30
262262
#define SV_LOOKINV 31
263263
#define SV_ITEMPRICE 32
264-
#define SV__FREE_FOR_USE4__ 33
264+
#define SV_AREAINFO 33
265265
#define SV_CEFFECT 34
266266
#define SV_UEFFECT 35
267267
#define SV_REALTIME 36

src/config.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ struct config_data config_data = {
1414
.dbuser = "root",
1515
.dbpass = "tgbdwf3h",
1616
.dbname = "merc35",
17-
.chathost = "localhost"};
17+
.chathost = "localhost",
18+
.svrkey = "4242"};
1819

1920
void config_set_name(char *name, char *value) {
2021
if (!strcmp(name, "dbhost")) {
@@ -37,6 +38,10 @@ void config_set_name(char *name, char *value) {
3738
config_data.chathost = strdup(value);
3839
return;
3940
}
41+
if (!strcmp(name, "svrkey")) {
42+
config_data.svrkey = strdup(value);
43+
return;
44+
}
4045
fprintf(stderr, "config_set: unknown name '%s'.\n", name);
4146
exit(1);
4247
}
@@ -123,4 +128,5 @@ void config_getenv(void) {
123128
if ((tmp = getenv("AS35_DBPASS"))) config_data.dbpass = tmp;
124129
if ((tmp = getenv("AS35_DBNAME"))) config_data.dbname = tmp;
125130
if ((tmp = getenv("AS35_CHATHOST"))) config_data.chathost = tmp;
131+
if ((tmp = getenv("AS35_SVRKEY"))) config_data.svrkey = tmp;
126132
}

src/config.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ struct config_data {
55
char *dbpass;
66
char *dbname;
77
char *chathost;
8+
char *svrkey;
89
};
910
extern struct config_data config_data;
1011

src/player.c

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@
5353
#include "questlog.h"
5454
#include "shrine.h"
5555
#include "spell.h"
56+
#include "config.h"
57+
58+
#define SERVER_PROTOCOL_VERSION 2
5659

5760
#define MAX_IDLE (TICKS * 30)
5861

@@ -350,10 +353,12 @@ static void read_login(int nr) {
350353
// clients v1 and better understand SV_PROTOCOL, so we tell them the server version
351354
if (player[nr]->client_version > 0) {
352355
buf[0] = SV_PROTOCOL;
353-
buf[1] = 1;
356+
buf[1] = SERVER_PROTOCOL_VERSION;
354357
psend(nr, buf, 2);
355358
}
356359

360+
player_areainfo(nr, 0);
361+
357362
if (!(ch[cn].flags & CF_AREACHANGE)) {
358363
show_motd(nr);
359364
show_clan_message(cn);
@@ -2839,6 +2844,33 @@ int get_player_version(int nr) {
28392844
int get_char_version(int cn) {
28402845
int nr;
28412846

2847+
if (!player) return 0;
2848+
28422849
if ((nr = ch[cn].player) && player[nr]) return player[nr]->client_version;
28432850
else return 0;
28442851
}
2852+
2853+
void player_areainfo(int nr, unsigned short cmd) {
2854+
char buf[80];
2855+
2856+
if (!player) return;
2857+
if (!player[nr]) return;
2858+
2859+
if (player[nr]->client_version < 2) return;
2860+
2861+
buf[0] = SV_AREAINFO;
2862+
*(unsigned short *)(buf + 1) = cmd;
2863+
2864+
switch (cmd) {
2865+
case AIC_SETID:
2866+
*(unsigned short *)(buf + 3) = (unsigned short)areaID;
2867+
*(unsigned short *)(buf + 5) = atoi(config_data.svrkey); // server_key: vanilla 3.5 is 2, default is 4242
2868+
break;
2869+
case AIC_CLEAR:
2870+
*(unsigned short *)(buf + 3) = 0u;
2871+
*(unsigned short *)(buf + 5) = 0u;
2872+
break;
2873+
}
2874+
2875+
psend(nr, buf, 7);
2876+
}

src/player.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,3 +158,7 @@ unsigned int get_player_addr(int nr);
158158
void sendquestlog(int cn, int nr);
159159
int get_player_version(int nr);
160160
int get_char_version(int cn);
161+
162+
#define AIC_SETID 0
163+
#define AIC_CLEAR 1
164+
void player_areainfo(int nr, unsigned short cmd);

src/random.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1251,6 +1251,7 @@ void create_dungeon(int cn, int co, int level, struct master_data *dat) {
12511251
say(cn, "This dungeon will collapse in %.2f minutes.", DUNGEONTIME / (TICKS * 60.0));
12521252

12531253
teleport_char_driver(co, xoff + 2, yoff + 58);
1254+
player_areainfo(ch[co].player, AIC_CLEAR);
12541255
}
12551256

12561257
void enter_dungeon(int cn, int co, int target, struct master_data *dat) {
@@ -1280,6 +1281,7 @@ void enter_dungeon(int cn, int co, int target, struct master_data *dat) {
12801281
say(cn, "This dungeon will collapse in %.2f minutes,", tmp / (TICKS * 60.0));
12811282

12821283
teleport_char_driver(co, (target % 4) * 61 + 4, (target / 4) * 61 + 60);
1284+
player_areainfo(ch[co].player, AIC_CLEAR);
12831285
}
12841286

12851287
void list_dungeon(int cn, struct master_data *dat) {

src/server.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,9 @@ int main(int argc, char *args[]) {
154154
printf(" ********************************************\n");
155155
printf("\n");
156156

157+
// load serverkey from file first so it can be overwritten by config
158+
config_file(".serverkey");
159+
157160
if (argc > 1) {
158161
while (1) {
159162
c = getopt(argc, args, "a:m:i:w:dhcs:f:e");

0 commit comments

Comments
 (0)