| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
#include "jacl.h" |
| 8 |
#include "language.h" |
| 9 |
#include "types.h" |
| 10 |
#include "prototypes.h" |
| 11 |
#include <string.h> |
| 12 |
|
| 13 |
|
| 14 |
static int jacl_whitespace(int character); |
| 15 |
|
| 16 |
void |
| 17 |
eachturn() |
| 18 |
{ |
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
TOTAL_MOVES->value++; |
| 24 |
execute("+eachturn"); |
| 25 |
strcpy(function_name, "eachturn_"); |
| 26 |
strcat(function_name, object[HERE]->label); |
| 27 |
execute(function_name); |
| 28 |
execute("+system_eachturn"); |
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
TIME->value = FALSE; |
| 37 |
} |
| 38 |
|
| 39 |
int |
| 40 |
get_here() |
| 41 |
{ |
| 42 |
|
| 43 |
|
| 44 |
if (player < 1 || player > objects) { |
| 45 |
badplrrun(player); |
| 46 |
terminate(44); |
| 47 |
} else if (object[player]->PARENT < 1 || object[player]->PARENT> objects || object[player]->PARENT== player) { |
| 48 |
badparrun(); |
| 49 |
terminate(44); |
| 50 |
} else { |
| 51 |
return (object[player]->PARENT); |
| 52 |
} |
| 53 |
|
| 54 |
|
| 55 |
return 1; |
| 56 |
} |
| 57 |
|
| 58 |
char * |
| 59 |
strip_return (char *string) |
| 60 |
{ |
| 61 |
|
| 62 |
int index; |
| 63 |
int length = strlen(string); |
| 64 |
|
| 65 |
for (index = 0; index < length; index++) { |
| 66 |
switch (string[index]) { |
| 67 |
case '\r': |
| 68 |
case '\n': |
| 69 |
string[index] = 0; |
| 70 |
break; |
| 71 |
} |
| 72 |
} |
| 73 |
|
| 74 |
return string; |
| 75 |
} |
| 76 |
|
| 77 |
int |
| 78 |
random_number() |
| 79 |
{ |
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
rand(); |
| 84 |
return (1 + (int) ((float) MAX_RAND->value * rand() / (RAND_MAX + 1.0))); |
| 85 |
} |
| 86 |
|
| 87 |
void |
| 88 |
create_paths(char *full_path) |
| 89 |
{ |
| 90 |
int index; |
| 91 |
char *last_slash; |
| 92 |
|
| 93 |
|
| 94 |
strcpy(game_file, full_path); |
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
last_slash = (char *) NULL; |
| 99 |
|
| 100 |
|
| 101 |
last_slash = strrchr(full_path, DIR_SEPARATOR); |
| 102 |
|
| 103 |
for (index = strlen(full_path); index >= 0; index--) { |
| 104 |
if (full_path[index] == DIR_SEPARATOR){ |
| 105 |
|
| 106 |
|
| 107 |
break; |
| 108 |
} else if (full_path[index] == '.') { |
| 109 |
full_path[index] = 0; |
| 110 |
break; |
| 111 |
} |
| 112 |
} |
| 113 |
|
| 114 |
|
| 115 |
if (last_slash == (char *) NULL) { |
| 116 |
|
| 117 |
strcpy(prefix, full_path); |
| 118 |
game_path[0] = 0; |
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
#ifdef __NDS__ |
| 123 |
sprintf (temp_buffer, "%c%s", DIR_SEPARATOR, game_file); |
| 124 |
#else |
| 125 |
sprintf (temp_buffer, ".%c%s", DIR_SEPARATOR, game_file); |
| 126 |
#endif |
| 127 |
strcpy (game_file, temp_buffer); |
| 128 |
} else { |
| 129 |
|
| 130 |
|
| 131 |
last_slash++; |
| 132 |
strcpy(prefix, last_slash); |
| 133 |
*last_slash = '\0'; |
| 134 |
strcpy(game_path, full_path); |
| 135 |
} |
| 136 |
|
| 137 |
#ifdef GLK |
| 138 |
|
| 139 |
sprintf(walkthru, "%s.walkthru", prefix); |
| 140 |
|
| 141 |
|
| 142 |
sprintf(bookmark, "%s.bookmark", prefix); |
| 143 |
|
| 144 |
|
| 145 |
#ifdef GARGLK |
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
sprintf(blorb, "%s/%s.blorb", game_path, prefix); |
| 150 |
#else |
| 151 |
sprintf(blorb, "%s.blorb", prefix); |
| 152 |
#endif |
| 153 |
#endif |
| 154 |
|
| 155 |
|
| 156 |
if (include_directory[0] == 0) { |
| 157 |
strcpy(include_directory, game_path); |
| 158 |
strcat(include_directory, INCLUDE_DIR); |
| 159 |
} |
| 160 |
|
| 161 |
if (temp_directory[0] == 0) { |
| 162 |
strcpy(temp_directory, game_path); |
| 163 |
strcat(temp_directory, TEMP_DIR); |
| 164 |
} |
| 165 |
|
| 166 |
if (data_directory[0] == 0) { |
| 167 |
strcpy(data_directory, game_path); |
| 168 |
strcat(data_directory, DATA_DIR); |
| 169 |
} |
| 170 |
} |
| 171 |
|
| 172 |
int |
| 173 |
jacl_whitespace(int character) |
| 174 |
{ |
| 175 |
|
| 176 |
switch (character) { |
| 177 |
case ':': |
| 178 |
case '\t': |
| 179 |
case ' ': |
| 180 |
return(TRUE); |
| 181 |
default: |
| 182 |
return(FALSE); |
| 183 |
} |
| 184 |
} |
| 185 |
|
| 186 |
char * |
| 187 |
stripwhite (char *string) |
| 188 |
{ |
| 189 |
int i; |
| 190 |
|
| 191 |
|
| 192 |
while (jacl_whitespace (*string)) string++; |
| 193 |
|
| 194 |
i = strlen (string) - 1; |
| 195 |
|
| 196 |
while (i >= 0 && ((jacl_whitespace (*(string+ i))) || *(string + i) == '\n' || *(string + i) == '\r')) i--; |
| 197 |
|
| 198 |
#ifdef _WIN32 |
| 199 |
i++; |
| 200 |
*(string + i) = '\r'; |
| 201 |
#endif |
| 202 |
i++; |
| 203 |
*(string + i) = '\n'; |
| 204 |
i++; |
| 205 |
*(string + i) = '\0'; |
| 206 |
|
| 207 |
return string; |
| 208 |
} |
| 209 |
|
| 210 |
void |
| 211 |
jacl_encrypt(char *string) |
| 212 |
{ |
| 213 |
int index, length; |
| 214 |
|
| 215 |
length = strlen(string); |
| 216 |
|
| 217 |
for (index = 0; index < length; index++) { |
| 218 |
if (string[index] == '\n' || string[index] == '\r') { |
| 219 |
return; |
| 220 |
} |
| 221 |
string[index] = string[index] ^ 255; |
| 222 |
} |
| 223 |
} |
| 224 |
|
| 225 |
void |
| 226 |
jacl_decrypt(char *string) |
| 227 |
{ |
| 228 |
int index, length; |
| 229 |
|
| 230 |
length = strlen(string); |
| 231 |
|
| 232 |
for (index = 0; index < length; index++) { |
| 233 |
if (string[index] == '\n' || string[index] == '\r') { |
| 234 |
return; |
| 235 |
} |
| 236 |
string[index] = string[index] ^ 255; |
| 237 |
} |
| 238 |
} |
| 239 |
|