blob: 1a50d0b4ce997b4d0c934aab3798f1785246a946 [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: 1.3 $
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}
47
48string Validate(string file)
49{
50 int x,y;
51 string path, name;
52
53 file = ::Validate(file);
54 if((sscanf(file, "%s[%d,%d]", name, x, y) == 3) &&
55 name == QueryProp(P_VALID_NAME) &&
56 (x >= QueryProp(P_MIN_X) && x <= QueryProp(P_MAX_X)) &&
57 (y >= QueryProp(P_MIN_Y) && y <= QueryProp(P_MAX_Y))
58 )
59 return file;
60}
61
62mixed CustomizeObject()
63{
64 string path, file, name;
65 int x,y;
66
67 if(!(file = ::CustomizeObject())) return 0;
68
69 path = QueryProp(P_COMPILER_PATH);
70 sscanf(file, "%s[%d,%d]", name, x, y);
71 name = QueryProp(P_VALID_NAME);
72 if(y < QueryProp(P_MAX_Y))
73 previous_object()->AddExit("norden",
74 path+"/"+name+"["+(x )+","+(y+1)+"]");
75 if(y > QueryProp(P_MIN_Y))
76 previous_object()->AddExit("sueden",
77 path+"/"+name+"["+(x )+","+(y-1)+"]");
78 if(x < QueryProp(P_MAX_X))
79 previous_object()->AddExit("osten" ,
80 path+"/"+name+"["+(x+1)+","+(y )+"]");
81 if(x > QueryProp(P_MIN_X))
82 previous_object()->AddExit("westen",
83 path+"/"+name+"["+(x-1)+","+(y )+"]");
84}
85