6 * Free a session's march list
8 void free_march_list(wcsession *wcf)
12 while (wcf->march != NULL) {
13 mptr = wcf->march->next;
23 * remove a room from the march list
25 void remove_march(const StrBuf *aaa)
27 struct march *mptr, *mptr2;
29 if (WC->march == NULL)
32 if (!strcasecmp(WC->march->march_name, ChrPtr(aaa))) {
33 mptr = WC->march->next;
39 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
40 if (!strcasecmp(mptr->march_name, ChrPtr(aaa))) {
41 mptr2->next = mptr->next;
53 * \brief Locate the room on the march list which we most want to go to.
55 * is measured given a "weight" of preference based on various factors.
56 * \param desired_floor the room number on the citadel server
57 * \return the roomname
59 char *pop_march(int desired_floor)
61 static char TheRoom[128];
66 struct march *mptr = NULL;
68 strcpy(TheRoom, "_BASEROOM_");
69 if (WC->march == NULL)
72 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
74 if ((strcasecmp(mptr->march_name, "_BASEROOM_")))
75 weight = weight + 10000;
76 if (mptr->march_floor == desired_floor)
77 weight = weight + 5000;
79 weight = weight + ((128 - (mptr->march_floor)) * 128);
80 weight = weight + (128 - (mptr->march_order));
82 if (weight > TheWeight) {
84 strcpy(TheRoom, mptr->march_name);
85 TheFloor = mptr->march_floor;
86 TheOrder = mptr->march_order;
95 * Goto next room having unread messages.
97 * We want to skip over rooms that the user has already been to, and take the
98 * user back to the lobby when done. The room we end up in is placed in
99 * newroom - which is set to 0 (the lobby) initially.
100 * We start the search in the current room rather than the beginning to prevent
101 * two or more concurrent users from dragging each other back to the same room.
106 struct march *mptr = NULL;
107 struct march *mptr2 = NULL;
113 * First check to see if the march-mode list is already allocated.
114 * If it is, pop the first room off the list and go there.
116 if (havebstr("startmsg")) {
121 if (WC->march == NULL) {
123 serv_getln(buf, sizeof buf);
125 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
126 if (IsEmptyStr(buf)) {
129 if (ELoop % 100 == 0)
134 extract_token(room_name, buf, 0, '|', sizeof room_name);
135 if (strcasecmp(room_name, ChrPtr(WC->wc_roomname))) {
136 mptr = (struct march *) malloc(sizeof(struct march));
138 safestrncpy(mptr->march_name, room_name, sizeof mptr->march_name);
139 mptr->march_floor = extract_int(buf, 2);
140 mptr->march_order = extract_int(buf, 3);
141 if (WC->march == NULL)
150 * add _BASEROOM_ to the end of the march list, so the user will end up
151 * in the system base room (usually the Lobby>) at the end of the loop
153 mptr = (struct march *) malloc(sizeof(struct march));
155 mptr->march_order = 0;
156 mptr->march_floor = 0;
157 strcpy(mptr->march_name, "_BASEROOM_");
158 if (WC->march == NULL) {
162 while (mptr2->next != NULL)
167 * ...and remove the room we're currently in, so a <G>oto doesn't make us
168 * walk around in circles
170 remove_march(WC->wc_roomname);
172 if (WC->march != NULL) {
173 next_room = NewStrBufPlain(pop_march(-1), -1);/*TODO: migrate march to strbuf */
175 next_room = NewStrBufPlain(HKEY("_BASEROOM_"));
179 smart_goto(next_room);
180 FreeStrBuf(&next_room);
184 * un-goto the previous room
190 if (havebstr("startmsg")) {
195 if (!strcmp(WC->ugname, "")) {
196 smart_goto(WC->wc_roomname);
199 serv_printf("GOTO %s", WC->ugname);
201 StrBuf_ServGetln(Buf);
202 if (GetServerStatus(Buf, NULL) != 2) {
203 smart_goto(WC->wc_roomname);
207 if (WC->uglsn >= 0L) {
208 serv_printf("SLRP %ld", WC->uglsn);
209 StrBuf_ServGetln(Buf);
212 StrBufAppendBufPlain(Buf, WC->ugname, -1, 0);
213 strcpy(WC->ugname, "");
220 void _gotonext(void) {
227 smart_goto(sbstr("room"));
238 WebcitAddUrlHandler(HKEY("gotonext"), _gotonext, NEED_URL);
239 WebcitAddUrlHandler(HKEY("skip"), gotonext, NEED_URL);
240 WebcitAddUrlHandler(HKEY("ungoto"), ungoto, NEED_URL);