/* * UserStartDrag: User wants to drag object under mouse pointer. If there is no * object there, do nothing. If there is more than one object, ask user which * one to pick up. If there is exactly one, begin dragging object. */ void UserStartDrag(void) { list_type objects, sel_list, l; int x, y; object_node *obj; /* Find out where in the the room the user clicked on, if anywhere */ if (!MouseToRoom(&x, &y)) return; objects = GetObjects3D(x, y, CLOSE_DISTANCE, OF_GETTABLE | OF_CONTAINER, 0); if (objects == NULL) return; if (objects->next == NULL) { SetCapture(hMain); capture = True; obj = (object_node *) objects->data; drag_object = obj->id; SetMainCursor(LoadCursor(hInst, MAKEINTRESOURCE(IDC_GETCURSOR))); } else { sel_list = DisplayLookList(hMain, GetString(hInst, IDS_GET), objects, LD_SINGLEAUTO); for (l = sel_list; l != NULL; l = l->next) RequestPickup(((room_contents_node *) (l->data))->obj.id); ObjectListDestroy(sel_list); } list_delete(objects); }
void UserCastSpell(void) { spell *sp = NULL, *temp; list_type sel_list, l; if (GetPlayer()->viewID && (GetPlayer()->viewID != GetPlayer()->id)) { if (!(GetPlayer()->viewFlags & REMOTE_VIEW_CAST)) return; } sel_list = DisplayLookList(cinfo->hMain, GetString(hInst, IDS_CAST), spells, LD_SORT); if (sel_list == NULL) return; /* Find spell in our private list */ temp = (spell *) sel_list->data; for (l = spells; l != NULL; l = l->next) { sp = (spell *) l->data; if (sp->obj.id == temp->obj.id) break; } if (sp == NULL) { debug(("Couldn't find selected spell in spell list!\n")); return; } list_delete(sel_list); PerformAction(A_CASTSPELL, sp); }