blob: 40e4bd0965f8de41ef01b8d5faa7222c1f028fff [file] [log] [blame]
MG Mud User88f12472016-06-24 23:31:02 +02001// MorgenGrauen MUDlib
2//
3// VR_COMPILER.C -- virtual room compiler
4//
5// $Date: 2002/08/28 09:57:18 $
6// $Revision: 6605 $
7/* $Log: vr_compiler.c,v $
8 * Revision 1.3 2002/08/28 09:57:18 Rikus
9 * auf strong_types umgestellt
10 *
11 * Revision 1.2 1994/07/27 14:48:18 Jof
12 * suid
13 *
14 * Revision 1.1 1994/02/01 19:47:57 Hate
15 * Initial revision
16 *
17*/
18
19// principle:
20// - inherit this object into your own 'virtual_compiler.c'
21// - customize Validate() and CustomizeObject() for you own sake
22//
23// * Validate() checks if a room filename given as argument (without path)
24// is valid and returns this filename with stripped '.c'!!
25// * CustomizeObject() uses the previous_object()->Function() strategy to
26// customize the standard object (for example to set a description)
27//
28// Properties: P_VALID_NAME, P_MIN_X, P_MAX_X, P_MIN_Y, P_MAX_Y
29
30#pragma strong_types
31
32inherit "/std/virtual/v_compiler";
33
34#define NEED_PROTOTYPES
35
36#include <thing/properties.h>
37#include <defines.h>
38#include <v_compiler.h>
39#include "/obj/virtual/vr_compiler.h"
40#include <sys_debug.h>
41
42void create()
43{
44 ::create();
45 SetProp(P_VALID_NAME, "raum");
46 seteuid(getuid());
47}
48
49string Validate(string file)
50{
51 int x,y;
52 string path, name;
53
54 file = ::Validate(file);
55 if((sscanf(file, "%s[%d,%d]", name, x, y) == 3) &&
56 name == QueryProp(P_VALID_NAME) &&
57 (x >= QueryProp(P_MIN_X) && x <= QueryProp(P_MAX_X)) &&
58 (y >= QueryProp(P_MIN_Y) && y <= QueryProp(P_MAX_Y))
59 )
60 return file;
61}
62
63mixed CustomizeObject()
64{
65 string path, file, name;
66 int x,y;
67
68 if(!(file = ::CustomizeObject())) return 0;
69
70 path = QueryProp(P_COMPILER_PATH);
71 sscanf(file, "%s[%d,%d]", name, x, y);
72 name = QueryProp(P_VALID_NAME);
73 if(y < QueryProp(P_MAX_Y))
74 previous_object()->AddExit("norden", path+"/"+name+"["+(x )+","+(y+1)+"]");
75 if(y > QueryProp(P_MIN_Y))
76 previous_object()->AddExit("sueden", path+"/"+name+"["+(x )+","+(y-1)+"]");
77 if(x < QueryProp(P_MAX_X))
78 previous_object()->AddExit("osten" , path+"/"+name+"["+(x+1)+","+(y )+"]");
79 if(x > QueryProp(P_MIN_X))
80 previous_object()->AddExit("westen", path+"/"+name+"["+(x-1)+","+(y )+"]");
81}