1 /** vim: set ts=4 sw=4 et tw=99:
3 * === Stripper for Metamod:Source ===
4 * Copyright (C) 2005-2009 David "BAILOPAN" Anderson
5 * No warranties of any kind.
6 * Based on the original concept of Stripper2 by botman
8 * License: see LICENSE.TXT
9 * ===================================
18 #include <sys/types.h>
24 stripper_game_t stripper_game;
27 #define EXPORT extern "C" __declspec(dllexport)
28 #elif defined __GNUC__
30 #define EXPORT extern "C" __attribute__ ((visibility("default")))
32 #define EXPORT extern "C"
37 parse_map(const char* map, const char* entities)
42 g_Stripper.SetEntityList(entities);
44 stripper_game.path_format(path,
46 "%s/%s/global_filters.cfg",
47 stripper_game.game_path,
48 stripper_game.stripper_cfg_path);
49 fp = fopen(path, "rt");
52 stripper_game.log_message("Could not find global filter file: %s", path);
57 g_Stripper.ApplyFileFilter(path);
60 stripper_game.path_format(path,
63 stripper_game.game_path,
64 stripper_game.stripper_cfg_path,
66 fp = fopen(path, "rt");
70 g_Stripper.ApplyFileFilter(path);
73 return g_Stripper.ToString();
79 return g_Stripper.ToString();
87 stripper_game.path_format(path,
90 stripper_game.game_path,
91 stripper_game.stripper_path);
94 DWORD attr = GetFileAttributes(path);
95 if ( (attr = INVALID_FILE_ATTRIBUTES) || (!(attr & FILE_ATTRIBUTE_DIRECTORY)) )
103 if (stat(path, &s) != 0)
109 if (!(S_ISDIR(s.st_mode)))
121 stripper_game.path_format(file,
125 stripper_game.get_map_name(),
127 FILE *fp = fopen(file, "rt");
133 FILE *fp = fopen(file, "wt");
134 fprintf(fp, "%s", g_Stripper.ToString());
137 stripper_game.log_message("Logged map %s to file %s", stripper_game.get_map_name(), file);
145 static stripper_core_t stripper_core =
154 LoadStripper(const stripper_game_t* game, stripper_core_t* core)
156 memcpy(&stripper_game, game, sizeof(stripper_game_t));
157 memcpy(core, &stripper_core, sizeof(stripper_core_t));
160 /* Overload a few things to prevent libstdc++ linking */
161 #if defined __linux__ || defined __APPLE__
162 extern "C" void __cxa_pure_virtual(void)
166 void *operator new(size_t size)
171 void *operator new[](size_t size)
176 void operator delete(void *ptr)
181 void operator delete[](void * ptr)