5 * Free a session's march list
7 void free_march_list(wcsession *wcf)
11 while (wcf->march != NULL) {
12 mptr = wcf->march->next;
22 * remove a room from the march list
24 void remove_march(const StrBuf *aaa)
26 struct march *mptr, *mptr2;
28 if (WC->march == NULL)
31 if (!strcasecmp(WC->march->march_name, ChrPtr(aaa))) {
32 mptr = WC->march->next;
38 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
39 if (!strcasecmp(mptr->march_name, ChrPtr(aaa))) {
40 mptr2->next = mptr->next;
52 * \brief Locate the room on the march list which we most want to go to.
54 * is measured given a "weight" of preference based on various factors.
55 * \param desired_floor the room number on the citadel server
56 * \return the roomname
58 char *pop_march(int desired_floor)
60 static char TheRoom[128];
65 struct march *mptr = NULL;
67 strcpy(TheRoom, "_BASEROOM_");
68 if (WC->march == NULL)
71 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
73 if ((strcasecmp(mptr->march_name, "_BASEROOM_")))
74 weight = weight + 10000;
75 if (mptr->march_floor == desired_floor)
76 weight = weight + 5000;
78 weight = weight + ((128 - (mptr->march_floor)) * 128);
79 weight = weight + (128 - (mptr->march_order));
81 if (weight > TheWeight) {
83 strcpy(TheRoom, mptr->march_name);
84 TheFloor = mptr->march_floor;
85 TheOrder = mptr->march_order;
94 * Goto next room having unread messages.
96 * We want to skip over rooms that the user has already been to, and take the
97 * user back to the lobby when done. The room we end up in is placed in
98 * newroom - which is set to 0 (the lobby) initially.
99 * We start the search in the current room rather than the beginning to prevent
100 * two or more concurrent users from dragging each other back to the same room.
105 struct march *mptr = NULL;
106 struct march *mptr2 = NULL;
112 * First check to see if the march-mode list is already allocated.
113 * If it is, pop the first room off the list and go there.
115 if (havebstr("startmsg")) {
116 readloop(readnew, eUseDefault);
120 if (WC->march == NULL) {
122 serv_getln(buf, sizeof buf);
124 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
125 if (IsEmptyStr(buf)) {
128 if (ELoop % 100 == 0)
133 extract_token(room_name, buf, 0, '|', sizeof room_name);
134 if (strcasecmp(room_name, ChrPtr(WC->CurRoom.name))) {
135 mptr = (struct march *) malloc(sizeof(struct march));
137 safestrncpy(mptr->march_name, room_name, sizeof mptr->march_name);
138 mptr->march_floor = extract_int(buf, 2);
139 mptr->march_order = extract_int(buf, 3);
140 if (WC->march == NULL)
149 * add _BASEROOM_ to the end of the march list, so the user will end up
150 * in the system base room (usually the Lobby>) at the end of the loop
152 mptr = (struct march *) malloc(sizeof(struct march));
154 mptr->march_order = 0;
155 mptr->march_floor = 0;
156 strcpy(mptr->march_name, "_BASEROOM_");
157 if (WC->march == NULL) {
161 while (mptr2->next != NULL)
166 * ...and remove the room we're currently in, so a <G>oto doesn't make us
167 * walk around in circles
169 remove_march(WC->CurRoom.name);
171 if (WC->march != NULL) {
172 next_room = NewStrBufPlain(pop_march(-1), -1);/*TODO: migrate march to strbuf */
174 next_room = NewStrBufPlain(HKEY("_BASEROOM_"));
178 smart_goto(next_room);
179 FreeStrBuf(&next_room);
183 * un-goto the previous room
189 if (havebstr("startmsg")) {
190 readloop(readnew, eUseDefault);
194 if (!strcmp(WC->ugname, "")) {
195 smart_goto(WC->CurRoom.name);
198 serv_printf("GOTO %s", WC->ugname);
200 StrBuf_ServGetln(Buf);
201 if (GetServerStatus(Buf, NULL) != 2) {
202 smart_goto(WC->CurRoom.name);
206 if (WC->uglsn >= 0L) {
207 serv_printf("SLRP %ld", WC->uglsn);
208 StrBuf_ServGetln(Buf);
211 StrBufAppendBufPlain(Buf, WC->ugname, -1, 0);
212 strcpy(WC->ugname, "");
219 void _gotonext(void) {
226 smart_goto(sbstr("room"));
237 WebcitAddUrlHandler(HKEY("gotonext"), "", 0, _gotonext, NEED_URL);
238 WebcitAddUrlHandler(HKEY("skip"), "", 0, gotonext, NEED_URL);
239 WebcitAddUrlHandler(HKEY("ungoto"), "", 0, ungoto, NEED_URL);