Ticket #7222: recall-time.patch

File recall-time.patch, 4.0 KB (added by Talvo, 23 months ago)

Patch to add the extra functionality into @chan/recall and crecall()

Line 
1*** src/extchat.orig.c  Thu Mar  1 01:03:00 2007
2--- src/extchat.c   Thu Mar  1 01:02:33 2007
3***************
4*** 3035,3041 ****
5  {
6    CHAN *chan;
7    CHANUSER *u;
8!   int start = -1, num_lines = 10;
9    char *p = NULL, *buf, *name;
10    time_t timestamp;
11    char *stamp;
12--- 3035,3043 ----
13  {
14    CHAN *chan;
15    CHANUSER *u;
16!   int start = -1, num_lines;
17!   int recall_timestring = 0;
18!   time_t recall_from;
19    char *p = NULL, *buf, *name;
20    time_t timestamp;
21    char *stamp;
22***************
23*** 3052,3062 ****
24    }
25 
26    if (!args[1] || !*args[1]) {
27!     /* nothing */
28    } else if (is_integer(args[1])) {
29      num_lines = parse_integer(args[1]);
30      if (num_lines == 0)
31        num_lines = INT_MAX;
32    } else {
33      safe_str(T(e_int), buff, bp);
34      return;
35--- 3054,3067 ----
36    }
37 
38    if (!args[1] || !*args[1]) {
39!     num_lines = 10;       /* default */
40    } else if (is_integer(args[1])) {
41      num_lines = parse_integer(args[1]);
42      if (num_lines == 0)
43        num_lines = INT_MAX;
44+   } else if (etime_to_secs(args[1], &num_lines)) {
45+     recall_timestring = 1;
46+     recall_from = (time_t) mudtime - num_lines;
47    } else {
48      safe_str(T(e_int), buff, bp);
49      return;
50***************
51*** 3101,3106 ****
52--- 3106,3121 ----
53      return;
54    }
55 
56+   if (recall_timestring) {
57+     start = -1;
58+     num_lines = 0;
59+     while (buf =
60+      iter_bufferq(ChanBufferQ(chan), &p, &speaker, &type, &timestamp)) {
61+       if (timestamp >= recall_from)
62+   num_lines++;
63+     }
64+     p = NULL;
65+   }
66    if (start < 0)
67      start = BufferQNum(ChanBufferQ(chan)) - num_lines;
68    if (isempty_bufferq(ChanBufferQ(chan))
69***************
70*** 3307,3315 ****
71  {
72    CHAN *chan;
73    CHANUSER *u;
74!   const char *lines;
75    const char *startpos;
76!   int num_lines = 10;     /* Default if none is given */
77    int start = -1;
78    int all;
79    char *p = NULL, *buf;
80--- 3322,3332 ----
81  {
82    CHAN *chan;
83    CHANUSER *u;
84!   char *lines;
85    const char *startpos;
86!   int num_lines;
87!   time_t recall_from;
88!   int recall_timestring = 0;
89    int start = -1;
90    int all;
91    char *p = NULL, *buf;
92***************
93*** 3335,3350 ****
94        num_lines = parse_integer(lines);
95        if (num_lines == 0)
96    num_lines = INT_MAX;
97      } else {
98        notify(player, T("How many lines did you want to recall?"));
99        return;
100      }
101    }
102    if (num_lines < 1) {
103      notify(player, T("How many lines did you want to recall?"));
104      return;
105    }
106-
107    test_channel(player, name, chan);
108    if (!Chan_Can_See(chan, player)) {
109      if (onchannel(player, chan))
110--- 3352,3371 ----
111        num_lines = parse_integer(lines);
112        if (num_lines == 0)
113    num_lines = INT_MAX;
114+     } else if (etime_to_secs(lines, &num_lines)) {
115+       recall_timestring = 1;
116+       recall_from = (time_t) mudtime - num_lines;
117      } else {
118        notify(player, T("How many lines did you want to recall?"));
119        return;
120      }
121+   } else {
122+     num_lines = 10;       /* default value */
123    }
124    if (num_lines < 1) {
125      notify(player, T("How many lines did you want to recall?"));
126      return;
127    }
128    test_channel(player, name, chan);
129    if (!Chan_Can_See(chan, player)) {
130      if (onchannel(player, chan))
131***************
132*** 3364,3369 ****
133--- 3385,3400 ----
134      notify(player, T("CHAT: That channel doesn't have a recall buffer."));
135      return;
136    }
137+   if (recall_timestring) {
138+     start = -1;
139+     num_lines = 0;
140+     while (buf =
141+      iter_bufferq(ChanBufferQ(chan), &p, &speaker, &type, &timestamp)) {
142+       if (timestamp >= recall_from)
143+   num_lines++;
144+     }
145+     p = NULL;
146+   }
147    if (start < 0)
148      start = BufferQNum(ChanBufferQ(chan)) - num_lines;
149    if (isempty_bufferq(ChanBufferQ(chan))
150***************
151*** 3371,3377 ****
152      notify(player, T("CHAT: Nothing to recall."));
153      return;
154    }
155-
156    all = (start <= 0 && num_lines >= BufferQNum(ChanBufferQ(chan)));
157    notify_format(player, T("CHAT: Recall from channel <%s>"), ChanName(chan));
158    while (start > 0) {
159--- 3402,3407 ----