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

Comparing deliantra/server/common/button.C (file contents):
Revision 1.3 by elmex, Tue Aug 29 17:29:27 2006 UTC vs.
Revision 1.6 by root, Sun Sep 3 00:18:39 2006 UTC

1/* 1/*
2 * static char *rcsid_button_c = 2 * static char *rcsid_button_c =
3 * "$Id: button.C,v 1.3 2006/08/29 17:29:27 elmex Exp $"; 3 * "$Id: button.C,v 1.6 2006/09/03 00:18:39 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
174 */ 174 */
175void push_button (object *op) 175void push_button (object *op)
176{ 176{
177 oblinkpt *obp = get_button_links (op); 177 oblinkpt *obp = get_button_links (op);
178 178
179 if (!obp)
180 return;
181
179 if (INVOKE_MAP (TRIGGER, op->map, ARG_INT64(obp->value), ARG_INT(op->value))) 182 if (INVOKE_MAP (TRIGGER, op->map, ARG_INT64(obp->value), ARG_INT(op->value)))
180 return; 183 return;
181 184
182 if (obp && obp->link)
183 activate_connection_link (obp->link, op->value, op); 185 activate_connection_link (obp->link, op->value, op);
184} 186}
185 187
186/* 188/*
187 * elmex: 189 * elmex:
188 * This activates a connection, similar to push_button (object *op) but it takes 190 * This activates a connection, similar to push_button (object *op) but it takes
195{ 197{
196 if (INVOKE_MAP (TRIGGER, map, ARG_INT64(connection), ARG_INT(state))) 198 if (INVOKE_MAP (TRIGGER, map, ARG_INT64(connection), ARG_INT(state)))
197 return; 199 return;
198 200
199 oblinkpt *obp = get_connection_links (map, connection); 201 oblinkpt *obp = get_connection_links (map, connection);
200 if (obp && obp->link) 202 if (obp)
201 activate_connection_link (obp->link, state); 203 activate_connection_link (obp->link, state);
202} 204}
203 205
204/* 206/*
205 * Updates everything connected with the button op. 207 * Updates everything connected with the button op.
217 obp = get_button_links (op); 219 obp = get_button_links (op);
218 /* LOG(llevDebug, "update_button: %s (%d)\n", op->name, op->count); */ 220 /* LOG(llevDebug, "update_button: %s (%d)\n", op->name, op->count); */
219 if (obp) 221 if (obp)
220 for (ol = obp->link; ol; ol = ol->next) { 222 for (ol = obp->link; ol; ol = ol->next) {
221 if (!ol->ob || ol->ob->count != ol->id) { 223 if (!ol->ob || ol->ob->count != ol->id) {
222 LOG(llevDebug, "Internal error in update_button (%s).\n", op->name); 224 LOG(llevDebug, "Internal error in update_button (%s).\n", &op->name);
223 continue; 225 continue;
224 } 226 }
225 tmp = ol->ob; 227 tmp = ol->ob;
226 if (tmp->type==BUTTON) { 228 if (tmp->type==BUTTON) {
227 for(ab=tmp->above,tot=0;ab!=NULL;ab=ab->above) 229 for(ab=tmp->above,tot=0;ab!=NULL;ab=ab->above)
280 oblinkpt *obp; 282 oblinkpt *obp;
281 for (obp = m->buttons; obp; obp = obp->next) 283 for (obp = m->buttons; obp; obp = obp->next)
282 for (ol = obp->link; ol; ol = ol->next) { 284 for (ol = obp->link; ol; ol = ol->next) {
283 if (!ol->ob || ol->ob->count != ol->id) { 285 if (!ol->ob || ol->ob->count != ol->id) {
284 LOG(llevError, "Internal error in update_button (%s (%dx%d):%d, connected %ld).\n", 286 LOG(llevError, "Internal error in update_button (%s (%dx%d):%d, connected %ld).\n",
285 ol->ob?ol->ob->name:"null", 287 ol->ob?(const char *)ol->ob->name:"null",
286 ol->ob?ol->ob->x:-1, 288 ol->ob?ol->ob->x:-1,
287 ol->ob?ol->ob->y:-1, 289 ol->ob?ol->ob->y:-1,
288 ol->id, 290 ol->id,
289 obp->value); 291 obp->value);
290 continue; 292 continue;
338 if ( ! QUERY_FLAG (sacrifice, FLAG_ALIVE) 340 if ( ! QUERY_FLAG (sacrifice, FLAG_ALIVE)
339 && ! QUERY_FLAG (sacrifice, FLAG_IS_LINKED) 341 && ! QUERY_FLAG (sacrifice, FLAG_IS_LINKED)
340 && sacrifice->type != PLAYER) 342 && sacrifice->type != PLAYER)
341 { 343 {
342 if ((ARCH_SACRIFICE(altar) == sacrifice->arch->name || 344 if ((ARCH_SACRIFICE(altar) == sacrifice->arch->name ||
343 ARCH_SACRIFICE(altar) == sacrifice->name || 345 ARCH_SACRIFICE(altar) == sacrifice->name ||
344 ARCH_SACRIFICE(altar) == sacrifice->slaying || 346 ARCH_SACRIFICE(altar) == sacrifice->slaying ||
345 (!strcmp(ARCH_SACRIFICE(altar),query_base_name(sacrifice,0)))) 347 (!strcmp(ARCH_SACRIFICE(altar),query_base_name(sacrifice,0))))
346 && NROF_SACRIFICE(altar) <= (sacrifice->nrof?sacrifice->nrof:1)) 348 && NROF_SACRIFICE(altar) <= (sacrifice->nrof?sacrifice->nrof:1))
347 return 1; 349 return 1;
348 if (strcmp (ARCH_SACRIFICE(altar), "money") == 0 350 if (strcmp (ARCH_SACRIFICE(altar), "money") == 0
349 && sacrifice->type == MONEY 351 && sacrifice->type == MONEY
554 } 556 }
555 trigger_move (op, push); 557 trigger_move (op, push);
556 return 1; 558 return 1;
557 559
558 default: 560 default:
559 LOG(llevDebug, "Unknown trigger type: %s (%d)\n", op->name, op->type); 561 LOG(llevDebug, "Unknown trigger type: %s (%d)\n", &op->name, op->type);
560 return 0; 562 return 0;
561 } 563 }
562} 564}
563 565
564void add_button_link(object *button, mapstruct *map, int connected) { 566void add_button_link(object *button, mapstruct *map, int connected) {
813 if (!map) return; 815 if (!map) return;
814 816
815 for (obp = map->buttons; obp; obp = obp->next) { 817 for (obp = map->buttons; obp; obp = obp->next) {
816 for (ol=obp->link; ol; ol=ol->next) { 818 for (ol=obp->link; ol; ol=ol->next) {
817 if (ol->id!=ol->ob->count) 819 if (ol->id!=ol->ob->count)
818 LOG(llevError,"verify_button_links: object %s on list is corrupt (%d!=%d)\n",ol->ob->name, ol->id, ol->ob->count); 820 LOG(llevError,"verify_button_links: object %s on list is corrupt (%d!=%d)\n", &ol->ob->name, ol->id, ol->ob->count);
819 } 821 }
820 } 822 }
821} 823}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines