MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / AddMessageToList

Function AddMessageToList

scripts/Geodomes.cpp:201–233  ·  view source on GitHub ↗

Adds a message to the list

Source from the content-addressed store, hash-verified

199
200// Adds a message to the list
201int AddMessageToList(char *name, char *msg) {
202 int pos;
203
204 // Make sure there is room in the list
205 if (num_messages >= MAX_SCRIPT_MESSAGES)
206 return false;
207
208 // Allocate memory for this message entry
209 pos = num_messages;
210 message_list[pos] = (tScriptMessage *)malloc(sizeof(tScriptMessage));
211 if (message_list[pos] == NULL)
212 return false;
213
214 // Allocate memory for the message name
215 message_list[pos]->name = (char *)malloc(strlen(name) + 1);
216 if (message_list[pos]->name == NULL) {
217 free(message_list[pos]);
218 return false;
219 }
220 strcpy(message_list[pos]->name, name);
221
222 // Allocate memory for the message name
223 message_list[pos]->message = (char *)malloc(strlen(msg) + 1);
224 if (message_list[pos]->message == NULL) {
225 free(message_list[pos]->name);
226 free(message_list[pos]);
227 return false;
228 }
229 strcpy(message_list[pos]->message, msg);
230 num_messages++;
231
232 return true;
233}
234
235// Removes any whitespace padding from the end of a string
236void RemoveTrailingWhitespace(char *s) {

Callers 1

ReadMessageFileFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected