174 ChangeWorkingDirectory(argv[0]); |
162 ChangeWorkingDirectory(argv[0]); |
175 |
163 |
176 _random_seeds[1][1] = _random_seeds[1][0] = _random_seeds[0][1] = _random_seeds[0][0] = time(NULL); |
164 _random_seeds[1][1] = _random_seeds[1][0] = _random_seeds[0][1] = _random_seeds[0][0] = time(NULL); |
177 |
165 |
178 return ttd_main(argc, argv); |
166 return ttd_main(argc, argv); |
179 } |
|
180 |
|
181 void DetermineBasePaths() |
|
182 { |
|
183 _paths.game_data_dir = MallocT<char>(MAX_PATH); |
|
184 ttd_strlcpy(_paths.game_data_dir, GAME_DATA_DIR, MAX_PATH); |
|
185 #if defined(SECOND_DATA_DIR) |
|
186 _paths.second_data_dir = MallocT<char>(MAX_PATH); |
|
187 ttd_strlcpy(_paths.second_data_dir, SECOND_DATA_DIR, MAX_PATH); |
|
188 #endif |
|
189 |
|
190 #if defined(USE_HOMEDIR) |
|
191 const char *homedir = getenv("HOME"); |
|
192 |
|
193 if (homedir == NULL) { |
|
194 const struct passwd *pw = getpwuid(getuid()); |
|
195 if (pw != NULL) homedir = pw->pw_dir; |
|
196 } |
|
197 |
|
198 _paths.personal_dir = str_fmt("%s" PATHSEP "%s", homedir, PERSONAL_DIR); |
|
199 #else /* not defined(USE_HOMEDIR) */ |
|
200 _paths.personal_dir = MallocT<char>(MAX_PATH); |
|
201 ttd_strlcpy(_paths.personal_dir, PERSONAL_DIR, MAX_PATH); |
|
202 |
|
203 /* check if absolute or relative path */ |
|
204 const char *s = strchr(_paths.personal_dir, PATHSEPCHAR); |
|
205 |
|
206 /* add absolute path */ |
|
207 if (s == NULL || _paths.personal_dir != s) { |
|
208 getcwd(_paths.personal_dir, MAX_PATH); |
|
209 AppendPathSeparator(_paths.personal_dir, MAX_PATH); |
|
210 ttd_strlcat(_paths.personal_dir, PERSONAL_DIR, MAX_PATH); |
|
211 } |
|
212 #endif /* defined(USE_HOMEDIR) */ |
|
213 |
|
214 AppendPathSeparator(_paths.personal_dir, MAX_PATH); |
|
215 AppendPathSeparator(_paths.game_data_dir, MAX_PATH); |
|
216 } |
167 } |
217 |
168 |
218 /** |
169 /** |
219 * Insert a chunk of text from the clipboard onto the textbuffer. Get TEXT clipboard |
170 * Insert a chunk of text from the clipboard onto the textbuffer. Get TEXT clipboard |
220 * and append this up to the maximum length (either absolute or screenlength). If maxlength |
171 * and append this up to the maximum length (either absolute or screenlength). If maxlength |