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

Comparing deliantra/server/server/move.c (file contents):
Revision 1.3 by root, Thu Feb 9 02:11:26 2006 UTC vs.
Revision 1.5 by root, Mon Mar 20 23:58:15 2006 UTC

1/* 1/*
2 * static char *rcsid_move_c = 2 * static char *rcsid_move_c =
3 * "$Id: move.c,v 1.3 2006/02/09 02:11:26 root Exp $"; 3 * "$Id: move.c,v 1.5 2006/03/20 23:58:15 root Exp $";
4 */ 4 */
5 5
6/* 6/*
7 CrossFire, A Multiplayer game for X-windows 7 CrossFire, A Multiplayer game for X-windows
8 8
128 /* we already have newx, newy, and m, so lets use them. 128 /* we already have newx, newy, and m, so lets use them.
129 * In addition, this fixes potential crashes, because multipart object was 129 * In addition, this fixes potential crashes, because multipart object was
130 * on edge of map, +=x, +=y doesn't make correct coordinates. 130 * on edge of map, +=x, +=y doesn't make correct coordinates.
131 */ 131 */
132 for(tmp = op; tmp != NULL; tmp = tmp->more) { 132 for(tmp = op; tmp != NULL; tmp = tmp->more) {
133 tmp->x = newx + tmp->arch->clone.x; 133 tmp->x += freearr_x[dir];
134 tmp->y = newy + tmp->arch->clone.y; 134 tmp->y += freearr_y[dir];
135 tmp->map = m; 135 tmp->map = get_map_from_coord(tmp->map, &tmp->x, &tmp->y);
136 } 136 }
137 137
138 /* insert_ob_in_map will deal with any tiling issues */ 138 /* insert_ob_in_map will deal with any tiling issues */
139 insert_ob_in_map(op, m, originator,0); 139 insert_ob_in_map(op, m, originator,0);
140 140
141 /* Hmmm. Should be possible for multispace players now */ 141 /* Hmmm. Should be possible for multispace players now */
142 if (op->type==PLAYER) { 142 if (op->type==PLAYER) {
143 esrv_map_scroll(&op->contr->socket, freearr_x[dir],freearr_y[dir]); 143 esrv_map_scroll(&op->contr->socket, freearr_x[dir],freearr_y[dir]);
144 op->contr->socket.update_look=1; 144 op->contr->socket.update_look=1;
145 op->contr->socket.look_position=0; 145 op->contr->socket.look_position=0;
146 }
147 else if (op->type == TRANSPORT) {
148 object *pl;
149
150 for (pl=op->inv; pl; pl=pl->below) {
151 if (pl->type == PLAYER) {
152 pl->contr->do_los=1;
153 pl->map = op->map;
154 pl->x = op->x;
155 pl->y = op->y;
156 esrv_map_scroll(&pl->contr->socket, freearr_x[dir],freearr_y[dir]);
157 pl->contr->socket.update_look=1;
158 pl->contr->socket.look_position=0;
159 }
160 }
146 } 161 }
147 162
148 return 1; /* this shouldn't be reached */ 163 return 1; /* this shouldn't be reached */
149} 164}
150 165
199 * be used close to each other and not have the player put to the 214 * be used close to each other and not have the player put to the
200 * one of another type. 215 * one of another type.
201 */ 216 */
202int teleport (object *teleporter, uint8 tele_type, object *user) 217int teleport (object *teleporter, uint8 tele_type, object *user)
203{ 218{
204 object *altern[120]; /* Better use c/malloc here in the future */ 219 object *altern;
205 int i,j,k,nrofalt=0; 220 int i,j,k,nrofalt=0;
206 object *other_teleporter, *tmp; 221 object *other_teleporter, *tmp;
207 mapstruct *m; 222 mapstruct *m;
208 sint16 sx, sy; 223 sint16 sx, sy;
209 224
227 242
228 while (other_teleporter) { 243 while (other_teleporter) {
229 if (other_teleporter->type == tele_type) break; 244 if (other_teleporter->type == tele_type) break;
230 other_teleporter = other_teleporter->above; 245 other_teleporter = other_teleporter->above;
231 } 246 }
232 if (other_teleporter) 247 if (other_teleporter && !(RANDOM() % ++nrofalt))
233 altern[nrofalt++]=other_teleporter; 248 altern = other_teleporter;
234 } 249 }
235 250
236 if(!nrofalt) { 251 if(!nrofalt) {
237 LOG(llevError,"No alternative teleporters around!\n"); 252 LOG(llevError,"No alternative teleporters around!\n");
238 return 0; 253 return 0;
239 } 254 }
240 255
241 other_teleporter=altern[RANDOM()%nrofalt]; 256 other_teleporter=altern;
242 k=find_free_spot(user,other_teleporter->map, 257 k=find_free_spot(user,other_teleporter->map,
243 other_teleporter->x,other_teleporter->y,1,9); 258 other_teleporter->x,other_teleporter->y,1,9);
244 259
245 /* if k==-1, unable to find a free spot. If this is shop 260 /* if k==-1, unable to find a free spot. If this is shop
246 * mat that the player is using, find someplace to move 261 * mat that the player is using, find someplace to move

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines