ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/quadland.C
(Generate patch)

Comparing deliantra/server/server/quadland.C (file contents):
Revision 1.8 by root, Tue May 3 17:12:15 2011 UTC vs.
Revision 1.13 by root, Wed May 4 19:39:43 2011 UTC

52 52
53 if (wall->flag [FLAG_IS_QUAD] && visible) 53 if (wall->flag [FLAG_IS_QUAD] && visible)
54 { 54 {
55 maptile *m = wall->map; 55 maptile *m = wall->map;
56 56
57 if (m->tile_path [TILE_UP]) 57 if (ob->map->tile_path [TILE_UP] && wall->map->tile_path [TILE_UP])
58 {
58 if (maptile *up = m->tile_available (TILE_UP)) 59 maptile *wall_up = wall->map->tile_available (TILE_UP);
60 maptile *ob_up = ob ->map->tile_available (TILE_UP);
61
62 if (wall_up && ob_up)
59 { 63 {
60 if (ob->blocked (up, ob->x, ob->y) || has_floor (up, ob->x, ob->y)) 64 if (ob->blocked (ob_up, ob->x, ob->y) || has_floor (ob_up, ob->x, ob->y))
61 ob->failmsg (format ("Ouch, you hit your head while climbing the %s! H<Didn't you see the ceiling?>", query_name (wall))); 65 ob->failmsg (format ("Ouch, you hit your head while climbing the %s! H<Didn't you see the ceiling? :)>", query_name (wall)));
62 //TODO: reduce health 66 //TODO: reduce health
63 else if (ob->blocked (up, wall->x, wall->y)) 67 else if (ob->blocked (wall_up, wall->x, wall->y))
64 ob->failmsg (format ("You try to climb up, but the %s is too high for you!", query_name (wall))); 68 ob->failmsg (format ("You try to climb up, but the %s is too high for you! H<No free space on top of this block.>", query_name (wall)));
65 //TODO: reduce health 69 //TODO: reduce health
66 else 70 else
67 { 71 {
68 ob->statusmsg (format ("You successfully climb up the %s.", query_name (wall))); 72 ob->statusmsg (format ("You successfully climb up the %s.", query_name (wall)));
69 // here we assume that ob is a player... 73 // here we assume that ob is a player...
70 ob->enter_map (up, wall->x, wall->y); 74 ob->enter_map (wall_up, wall->x, wall->y);
71 } 75 }
72 } 76 }
73 else 77 else
74 ob->failmsg (format ("You try to climb the %s, but you fall down! H<Try again.>", query_name (wall))); 78 ob->failmsg (format ("You try to climb the %s, but you fall down! H<Try again.>", query_name (wall)));
79 }
75 else 80 else
76 ob->failmsg (format ("You fail to climb up the %s! H<You cannot climb up here.>", query_name (wall))); 81 ob->failmsg (format ("You fail to climb up the %s! H<You cannot climb up here.>", query_name (wall)));
77 82
78 83
79 return; 84 return;
90 } 95 }
91} 96}
92 97
93///////////////////////////////////////////////////////////////////////////// 98/////////////////////////////////////////////////////////////////////////////
94 99
95// this mapspace has changed - potentialyl activate dormant physics objects 100physics_queue::physics_queue ()
96// in the vicinity 101{
102 i = 0;
103}
104
105object *
106physics_queue::pop ()
107{
108 if (expect_true (i < size ()))
109 return (*this)[i++];
110
111 i = 0;
112 clear ();
113 return 0;
114}
115
116inline unsigned int
117queue_of (tick_t tick)
118{
119 return tick & (PHYSICS_QUEUES - 1);
120}
97 121
98void update_physics (maptile *m, int x, int y) 122void update_physics (maptile *m, int x, int y)
99{ 123{
100} 124}
101 125
102// handle physics updates 126// handle physics updates
103void move_physics (object *ob) 127void move_physics (object *ob)
104{ 128{
129}
130
131int
132maptile::run_physics (tick_t tick, int max_objects)
133{
134 int orig_max_object = max_objects;
135 physics_queue &q = pq [queue_of (server_tick)];
136
137 while (object *ob = q.pop ())
138 {
139 --max_objects;
140
141 //printf ("handling ob %s\n", ob->debug_desc());//D
142
143 if (max_objects <= 0)
144 break;
145 }
146
147 return orig_max_object - max_objects;
148}
149
150void
151maptile::queue_physics (object *ob, int after)
152{
153 if (!ob->flag [FLAG_PHYSICS_QUEUE])
154 pq [queue_of (server_tick + min (PHYSICS_QUEUES - 1, after))].push_back (ob);
155}
156
157static void
158queue_physics_at (maptile *m, int x, int y)
159{
160 mapspace &ms = m->at (x, y);
161
162 for (object *ob = ms.bot; ob; ob = ob->above)
163 if (ob->type == PHYSICS)
164 m->queue_physics (ob);
165}
166
167// this mapspace has changed - potentially activate dormant physics objects
168// in the vicinity. vicinity is the 4 spaces around in the same z layer, and above and below.
169// TODO: maybe include diagonals in the same z-layer?
170void
171maptile::queue_physics_at (int x, int y)
172{
173 if (maptile *m = tile_available (TILE_DOWN))
174 ::queue_physics_at (m, x, y);
175
176 if (maptile *m = tile_available (TILE_UP))
177 ::queue_physics_at (m, x, y);
178
179 for (int dir = 1; dir < 8; dir += 2)
180 {
181 mapxy pos (this, x, y);
182 pos.move (dir);
183 if (pos.normalise ())
184 ::queue_physics_at (pos.m, pos.x, pos.y);
185 }
186}
187
188void
189maptile::post_load_physics ()
190{
191 for (mapspace *ms = spaces + size (); ms-- > spaces; )
192 for (object *tmp = ms->bot; tmp; tmp = tmp->above)
193 if (tmp->type == PHYSICS)
194 queue_physics (tmp);
105} 195}
106 196
107///////////////////////////////////////////////////////////////////////////// 197/////////////////////////////////////////////////////////////////////////////
108 198
109#define FANCY_GRAPHICS 0 199#define FANCY_GRAPHICS 0
165 int h = 1000000; // height form heightmap 255 int h = 1000000; // height form heightmap
166 256
167 // the continent increases in height from 0 to ~700 levels in the absence of anything else 257 // the continent increases in height from 0 to ~700 levels in the absence of anything else
168 // thats about one step every 7 maps. 258 // thats about one step every 7 maps.
169 int base_height = blend (0, 300, xy_gradient, 0.2f, 0.9f); 259 int base_height = blend (0, 300, xy_gradient, 0.2f, 0.9f);
170 int river_height = base_height * 9 / 10; 260 int river_height = base_height; // * 9 / 10;
171 261
172 // add this to rivers to "dry them out" 262 // add this to rivers to "dry them out"
173 float dry_out = max (0.f, lerp (xy_gradient, 0.7f, 1.f, 0.f, 0.3f)); 263 float dry_out = max (0.f, lerp (xy_gradient, 0.7f, 1.f, 0.f, 0.3f));
174 264
175 static frac2d river_gen (2); 265 static frac2d river_gen (2);
176 float river1 = abs (river_gen.fBm (P * 0.001 + perturb * 4)) + dry_out; 266 float river1 = abs (river_gen.fBm (P * 0.001 + perturb * 4)) + dry_out;
177 float river2 = river_gen.ridgedmultifractal (P * 0.04, 0.8, 10) - y_gradient * 0.2 - 0.16 - dry_out; 267 float river2 = river_gen.ridgedmultifractal (P * 0.04, 0.8, 10) - y_gradient * 0.2 - 0.16 - dry_out;
178 268
179 float valley = river1 - 0.2f; 269 float valley = river1 - 0.2f;
180 270
181 static frac2d mountain_gen (8, 2.14, 0.5); 271 static frac2d mountain_gen (6, 2.14, 0.5);
182 float mountain = mountain_gen.ridgedmultifractal (P * 0.004); 272 float mountain = mountain_gen.ridgedmultifractal (P * 0.004);
183 273
184 //TODO: mountains should not lower the height, should they? 274 //TODO: mountains should not lower the height, should they?
185 t = valley < 0 ? T_VALLEY : T_MOUNTAIN; 275 t = valley < 0 ? T_VALLEY : T_MOUNTAIN;
186 c = blend0 (vec3d (0, 0.8, 0), vec3d (0.8, 0, 0), valley, 0.1f); 276 c = blend0 (vec3d (0, 0.8, 0), vec3d (0.8, 0, 0), valley, 0.1f);
187 h = blend0 (base_height + continent * 300, base_height + mountain * xy_gradient * 400, valley, 0.1f); 277 h = blend0 (base_height + continent * 3, base_height + mountain * xy_gradient * 100, valley, 0.1f);
188 278
189 if (river1 < 0.01f) 279 if (river1 < 0.01f)
190 { 280 {
191 // main rivers - they cut deeply into the mountains (base_height * 0.9f) 281 // main rivers - they cut deeply into the mountains (base_height * 0.9f)
192 t = T_RIVER; 282 t = T_RIVER;
193 c = vec3d (0.2, 0.2, 1); 283 c = vec3d (0.2, 0.2, 1);
194 h0 = river_height; 284 h0 = river_height;
195 min_it (h, river_height + lerp<float> (river1, 0.f, 0.01f, -20, -1)); 285 min_it (h, river_height + lerp<float> (river1, 0.f, 0.01f, -10, -1));
196 } 286 }
197 287
198 if (river2 > 0) 288 if (river2 > 0)
199 { 289 {
200 t = T_RIVER; 290 t = T_RIVER;
201 c = vec3d (0.2, 0.2, 1); 291 c = vec3d (0.2, 0.2, 1);
202 h0 = river_height; 292 h0 = river_height;
203 min_it (h, river_height + lerp<float> (river1, 0.f, 0.01f, -5, -1)); 293 min_it (h, river_height + max (-5, lerp<float> (river2, 0.01f, 0, -4, -1)));
204 } 294 }
205 295
206 if (continent < 0) 296 if (continent < 0)
207 { 297 {
208 t = T_OCEAN; 298 t = T_OCEAN;
299 h0 = 0;
209 min_it (h, min (continent * 200, -1)); 300 min_it (h, min (continent * 200, -1));
210 c = vec3d (0, 0, 1); 301 c = vec3d (0, 0, 1);
211 } 302 }
212 303
213 // now we have the base height, and base terrain 304 // now we have the base height, and base terrain
232 { 323 {
233 t = T_ACQUIFER; 324 t = T_ACQUIFER;
234 c = vec3d (1,1,1); 325 c = vec3d (1,1,1);
235 } 326 }
236 } 327 }
328
329 //printf ("+%d+%d %d z %d h %d,%d\n", mx, my, t, z, h,h0);//D
237 330
238 // TODO: caves 331 // TODO: caves
239 // TODO: chees areas 332 // TODO: chees areas
240 // TODO: minerals 333 // TODO: minerals
241 // TODO: monsters 334 // TODO: monsters
281 374
282 case T_UNDERGROUND: 375 case T_UNDERGROUND:
283 // todo, use a fractal 376 // todo, use a fractal
284 if (z < h - 10) 377 if (z < h - 10)
285 { 378 {
286 arch_floor = shstr ("quad_dirt_floor"); 379 arch_floor = shstr ("quad_stone_floor");
287 arch_wall = shstr ("quad_dirt_wall"); 380 arch_wall = shstr ("quad_stone_wall");
288 } 381 }
289 else 382 else
290 { 383 {
291 arch_floor = shstr ("quad_stone_floor"); 384 arch_floor = shstr ("quad_dirt_floor");
292 arch_wall = shstr ("quad_stone_wall"); 385 arch_wall = shstr ("quad_dirt_wall");
293 } 386 }
294 break; 387 break;
295 388
296 case T_ACQUIFER: 389 case T_ACQUIFER:
297 arch_wall = shstr ("quad_water_wall"); 390 arch_wall = shstr ("quad_water_wall");
412 } 505 }
413#endif 506#endif
414 507
415 exit (0); 508 exit (0);
416} 509}
510

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines