| 59 | static bool IsInexistent(const float *, int); |
| 60 | |
| 61 | int main(int argc, const char *argv[]) |
| 62 | { |
| 63 | CCmdlineFix CmdlineFix(&argc, &argv); |
| 64 | log_set_global_logger_default(); |
| 65 | |
| 66 | if(argc != 10) |
| 67 | { |
| 68 | dbg_msg("map_replace_area", "Invalid arguments"); |
| 69 | dbg_msg("map_replace_area", "Usage: %s <from_map> <from_x> <from_y> <to_map> <to_x> <to_y> <width> <height> <output_map>", argv[0]); |
| 70 | dbg_msg("map_replace_area", "Note: use game layer tiles as a reference for both coordinates and sizes"); |
| 71 | |
| 72 | return -1; |
| 73 | } |
| 74 | |
| 75 | char aaMapNames[3][64]; |
| 76 | str_copy(aaMapNames[0], argv[1]); //from_map |
| 77 | str_copy(aaMapNames[1], argv[4]); //to_map |
| 78 | str_copy(aaMapNames[2], argv[9]); //output_map |
| 79 | |
| 80 | float aaaGameAreas[2][2][2]; |
| 81 | |
| 82 | for(int i = 0; i < 2; i++) |
| 83 | { |
| 84 | aaaGameAreas[i][0][0] = str_tofloat(argv[2 + i * 3]) * 32; //x |
| 85 | aaaGameAreas[i][1][0] = str_tofloat(argv[3 + i * 3]) * 32; //y |
| 86 | aaaGameAreas[i][0][1] = aaaGameAreas[i][0][0] + str_tofloat(argv[7]) * 32; //x + width |
| 87 | aaaGameAreas[i][1][1] = aaaGameAreas[i][1][0] + str_tofloat(argv[8]) * 32; //y + height |
| 88 | } |
| 89 | |
| 90 | cmdline_free(argc, argv); |
| 91 | |
| 92 | dbg_msg("map_replace_area", "from_map='%s'; to_map='%s'; from_area='%fx,%fy'; to_area='%fx,%fy'; area_width='%fpx'; area_height='%fpx'; output_map='%s'", |
| 93 | aaMapNames[0], aaMapNames[1], aaaGameAreas[0][0][0], aaaGameAreas[0][1][0], aaaGameAreas[1][0][0], aaaGameAreas[1][1][0], |
| 94 | aaaGameAreas[0][0][1] - aaaGameAreas[0][0][0], aaaGameAreas[0][1][1] - aaaGameAreas[0][1][0], aaMapNames[2]); |
| 95 | |
| 96 | std::unique_ptr<IStorage> pStorage = CreateLocalStorage(); |
| 97 | if(!pStorage) |
| 98 | { |
| 99 | log_error("map_replace_area", "Error creating local storage"); |
| 100 | return -1; |
| 101 | } |
| 102 | |
| 103 | for(int i = 0; i < 1024; i++) |
| 104 | { |
| 105 | g_apNewData[i] = g_apNewItem[i] = nullptr; |
| 106 | g_aNewDataSize[i] = 0; |
| 107 | } |
| 108 | |
| 109 | return ReplaceArea(pStorage.get(), aaMapNames, aaaGameAreas) ? 0 : 1; |
| 110 | } |
| 111 | |
| 112 | bool ReplaceArea(IStorage *pStorage, const char aaMapNames[3][64], const float aaaGameAreas[][2][2]) |
| 113 | { |
nothing calls this directly
no test coverage detected