Crossfire Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
CF: Patch: unlimited apartments
Hi,
the following patch is a surprisingly simple patch to allow every
player to have his/her own apartment.
It works by treating the map-directory "/apartments/" in a special way.
Whenever a player enters the map "/apartments/apartments", it will be
changed to "/apartments/<player name>/apartments"; if a map
"/apartments/*" is to be loaded (i.e. not as a temp map), the second
path part is stripped out.
That way, the map /apartments/apartments can be a map containing apartments
(and possibly a place to buy a key) which is private for all players,
and it can lead to other private maps. I'll make a reasonable apartments
map for this feature, but haven't had the time to do it (I have installed
an house from our apartment city, which was designed by Florian Beck
and debugged by me :-) on my server for the time being, but this house
is not a good apartment).
Besides the fact that every player gets an apartment, there is another
advantage: if a server admin doesn't like the feature, it can easily
be turned off by not installing the /apartments/apartments map.
------------------------------ Cut ------------------------------
diff -r -C 5 crossfire-0.94.0/server/main.c /usr/stud/stieber/crossfire/server/main.c
*** crossfire-0.94.0/server/main.c Sun Feb 8 06:26:18 1998
--- /usr/stud/stieber/crossfire/server/main.c Wed Mar 25 14:29:14 1998
***************
*** 219,228 ****
--- 219,229 ----
* until that time --MSW
*/
mapstruct *m, dummy_map;
int x=0, y=0, removed=QUERY_FLAG(op,FLAG_REMOVED);
char *newpath=NULL, *lastlevel=NULL;
+ char NameBuffer[MAX_BUF];
int oldx = (-1), oldy = (-1), last_x = op->x, last_y = op->y;
dummy_map.pending = (objectlink *) NULL;
dummy_map.in_memory = MAP_LOADING;
***************
*** 245,254 ****
--- 246,261 ----
* map he is on right now
*/
if(!newpath)
newpath = op->map->path;
+ if (op->type==PLAYER && strcmp(newpath,"/apartments/apartments")==0)
+ {
+ sprintf(NameBuffer,"/apartments/%s/apartments",op->name);
+ newpath=NameBuffer;
+ }
+
/* See if the map actually exists */
if (!has_been_loaded(newpath) && check_path(newpath) == -1) {
sprintf(buf,"The %s is closed.", exit_ob->name);
new_draw_info(NDI_UNIQUE, 0,op, buf);
return;
diff -r -C 5 crossfire-0.94.0/common/map.c /usr/stud/stieber/crossfire/common/map.c
*** crossfire-0.94.0/common/map.c Sun Feb 8 06:26:15 1998
--- /usr/stud/stieber/crossfire/common/map.c Wed Mar 25 14:38:36 1998
***************
*** 100,117 ****
--- 100,129 ----
* and returns the pointer to a static array containing the result.
*/
char *create_pathname (char *name) {
static char buf[MAX_BUF];
+ char Buffer[MAX_BUF];
+ if (strncmp("/apartments/",name,12)==0)
+ {
+ char *t;
+
+ for (t=name+12; *t!='/'; t++)
+ ;
+ sprintf(Buffer,"/apartments%s",t);
+ name=Buffer;
+ }
+
/* Why? having extra / doesn't confuse unix anyplace? Dependancies
* someplace else in the code? msw 2-17-97
*/
if (*name == '/')
sprintf (buf, "%s/%s%s", settings.libdir, settings.mapdir, name);
else
sprintf (buf, "%s/%s/%s", settings.libdir, settings.mapdir, name);
+
return (buf);
}
#ifdef UNIQUE_ITEMS
/*
------------------------------ Cut ------------------------------
--
Christian (Icho/Gandhi/Ribald @sunbroy53.informatik.tu-muenchen.de, 13326)
[to unsubscribe etc., send mail to crossfire-request@ifi.uio.no]