diff --git a/src/Bitmap.c b/src/Bitmap.c index 539369541..274fcfce5 100644 --- a/src/Bitmap.c +++ b/src/Bitmap.c @@ -15,7 +15,7 @@ BitmapCol BitmapCol_Scale(BitmapCol value, float t) { return value; } -void Bitmap_CopyBlock(int srcX, int srcY, int dstX, int dstY, Bitmap* src, Bitmap* dst, int size) { +void Bitmap_UNSAFE_CopyBlock(int srcX, int srcY, int dstX, int dstY, Bitmap* src, Bitmap* dst, int size) { int x, y; for (y = 0; y < size; y++) { BitmapCol* srcRow = Bitmap_GetRow(src, srcY + y) + srcX; diff --git a/src/Bitmap.h b/src/Bitmap.h index 5788443ce..fbc2768c4 100644 --- a/src/Bitmap.h +++ b/src/Bitmap.h @@ -48,7 +48,7 @@ typedef struct Bitmap_ { uint8_t* Scan0; int Width, Height; } Bitmap; /* Copies a rectangle of pixels from one bitmap to another. */ /* NOTE: If src and dst are the same, src and dst rectangles MUST NOT overlap. */ /* NOTE: Rectangles are NOT checked for whether they lie inside the bitmaps. */ -void Bitmap_CopyBlock(int srcX, int srcY, int dstX, int dstY, Bitmap* src, Bitmap* dst, int size); +void Bitmap_UNSAFE_CopyBlock(int srcX, int srcY, int dstX, int dstY, Bitmap* src, Bitmap* dst, int size); /* Allocates a new bitmap of the given dimensions. */ /* NOTE: You are responsible for freeing its memory! */ void Bitmap_Allocate(Bitmap* bmp, int width, int height); diff --git a/src/Http.c b/src/Http.c index 99ddef82a..4a97e6329 100644 --- a/src/Http.c +++ b/src/Http.c @@ -274,7 +274,7 @@ static void Http_ParseHeader(struct HttpRequest* req, const String* line) { valueEnd = String_IndexOf(&tmp, ';'); if (valueEnd >= 0) tmp.length = valueEnd; - req->Cookies->Separator = '='; + req->Cookies->separator = '='; EntryList_Set(req->Cookies, &name, &tmp); } } @@ -298,12 +298,12 @@ static void Http_SetRequestHeaders(struct HttpRequest* req) { } if (req->Data) Http_AddHeader("Content-Type", &contentType); - if (!req->Cookies || !req->Cookies->Entries.count) return; + if (!req->Cookies || !req->Cookies->entries.count) return; String_InitArray(cookies, cookiesBuffer); - for (i = 0; i < req->Cookies->Entries.count; i++) { + for (i = 0; i < req->Cookies->entries.count; i++) { if (i) String_AppendConst(&cookies, "; "); - str = StringsBuffer_UNSAFE_Get(&req->Cookies->Entries, i); + str = StringsBuffer_UNSAFE_Get(&req->Cookies->entries, i); String_AppendString(&cookies, &str); } Http_AddHeader("Cookie", &cookies); diff --git a/src/Input.c b/src/Input.c index 3323dc12b..71ecfa05f 100644 --- a/src/Input.c +++ b/src/Input.c @@ -320,9 +320,9 @@ void Hotkeys_Init(void) { uint8_t modifiers; bool more; - for (i = 0; i < Options.Entries.count; i++) { - entry = StringsBuffer_UNSAFE_Get(&Options.Entries, i); - String_UNSAFE_Separate(&entry, Options.Separator, &key, &value); + for (i = 0; i < Options.entries.count; i++) { + entry = StringsBuffer_UNSAFE_Get(&Options.entries, i); + String_UNSAFE_Separate(&entry, Options.separator, &key, &value); if (!String_CaselessStarts(&key, &prefix)) continue; /* Format is: key&modifiers = more-input&text */ diff --git a/src/Options.c b/src/Options.c index 5a3342610..db9be7fc1 100644 --- a/src/Options.c +++ b/src/Options.c @@ -14,7 +14,7 @@ static StringsBuffer Options_Changed; int Options_ChangedCount(void) { return Options_Changed.count; } void Options_Free(void) { - StringsBuffer_Clear(&Options.Entries); + StringsBuffer_Clear(&Options.entries); StringsBuffer_Clear(&Options_Changed); } @@ -138,17 +138,17 @@ void Options_Load(void) { String entry, key, value; int i; - if (!Options.Path) { + if (!Options.path) { EntryList_Init(&Options, "options-default.txt", '='); EntryList_Init(&Options, "options.txt", '='); } else { /* Reset all the unchanged options */ - for (i = Options.Entries.count - 1; i >= 0; i--) { - entry = StringsBuffer_UNSAFE_Get(&Options.Entries, i); + for (i = Options.entries.count - 1; i >= 0; i--) { + entry = StringsBuffer_UNSAFE_Get(&Options.entries, i); String_UNSAFE_Separate(&entry, '=', &key, &value); if (Options_HasChanged(&key)) continue; - StringsBuffer_Remove(&Options.Entries, i); + StringsBuffer_Remove(&Options.entries, i); } /* Load only options which have not changed */ diff --git a/src/Platform.c b/src/Platform.c index c42eba644..037ec2ff3 100644 --- a/src/Platform.c +++ b/src/Platform.c @@ -993,11 +993,11 @@ static ReturnCode FontData_Init(const String* path, struct FontData* data, FT_Op void Font_GetNames(StringsBuffer* buffer) { String entry, name, path; int i; - if (!font_list.Entries.count) Font_Init(); + if (!font_list.entries.count) Font_Init(); - for (i = 0; i < font_list.Entries.count; i++) { - entry = StringsBuffer_UNSAFE_Get(&font_list.Entries, i); - String_UNSAFE_Separate(&entry, font_list.Separator, &name, &path); + for (i = 0; i < font_list.entries.count; i++) { + entry = StringsBuffer_UNSAFE_Get(&font_list.entries, i); + String_UNSAFE_Separate(&entry, font_list.separator, &name, &path); /* Only want Regular fonts here */ if (name.length < 2 || name.buffer[name.length - 1] != 'R') continue; @@ -1016,7 +1016,7 @@ static String Font_LookupOf(const String* fontName, const char type) { String Font_Lookup(const String* fontName, int style) { String path; - if (!font_list.Entries.count) Font_Init(); + if (!font_list.entries.count) Font_Init(); path = String_Empty; if (style & FONT_STYLE_BOLD) path = Font_LookupOf(fontName, 'B'); @@ -1132,9 +1132,9 @@ static void Font_DirCallback(const String* path, void* obj) { if (String_CaselessEnds(path, &fonExt)) return; /* If font is already known good, skip it */ - for (i = 0; i < font_list.Entries.count; i++) { - entry = StringsBuffer_UNSAFE_Get(&font_list.Entries, i); - String_UNSAFE_Separate(&entry, font_list.Separator, &name, &value); + for (i = 0; i < font_list.entries.count; i++) { + entry = StringsBuffer_UNSAFE_Get(&font_list.entries, i); + String_UNSAFE_Separate(&entry, font_list.separator, &name, &value); String_UNSAFE_Separate(&value, ',', &fontPath, &index); if (String_CaselessEquals(path, &fontPath)) return; @@ -1604,7 +1604,7 @@ ReturnCode Process_StartOpen(const String* args) { } ReturnCode Process_StartShell(void) { - static const String args = String_FromConst("cmd.exe /C start cmd /C update.bat"); + static const String args = String_FromConst("cmd.exe /C start cmd /C " UPDATE_FILENAME); TCHAR str[300]; /* args must be modifiable, otherwise access violation */ Platform_ConvertString(str, &args); diff --git a/src/Resources.c b/src/Resources.c index fba3c5513..9ffb8bc77 100644 --- a/src/Resources.c +++ b/src/Resources.c @@ -409,11 +409,11 @@ static ReturnCode ModernPatcher_PatchTile(struct Stream* data, struct TilePatch* ReturnCode res; if ((res = Png_Decode(&bmp, data))) return res; - Bitmap_CopyBlock(0, 0, tile->x1 * 16, tile->y1 * 16, &bmp, &terrainBmp, 16); + Bitmap_UNSAFE_CopyBlock(0, 0, tile->x1 * 16, tile->y1 * 16, &bmp, &terrainBmp, 16); /* only quartz needs copying to two tiles */ if (tile->y2) { - Bitmap_CopyBlock(0, 0, tile->x2 * 16, tile->y2 * 16, &bmp, &terrainBmp, 16); + Bitmap_UNSAFE_CopyBlock(0, 0, tile->x2 * 16, tile->y2 * 16, &bmp, &terrainBmp, 16); } Mem_Free(bmp.Scan0); @@ -441,7 +441,7 @@ static ReturnCode ModernPatcher_MakeAnimations(struct Stream* s, struct Stream* Bitmap_Init(anim, 512, 16, anim_data); for (i = 0; i < 512; i += 16) { - Bitmap_CopyBlock(0, i, i, 0, &bmp, &anim, 16); + Bitmap_UNSAFE_CopyBlock(0, i, i, 0, &bmp, &anim, 16); } Mem_Free(bmp.Scan0); @@ -504,7 +504,7 @@ static ReturnCode TexPatcher_NewFiles(struct Stream* s) { } static void TexPatcher_PatchTile(Bitmap* src, int srcX, int srcY, int dstX, int dstY) { - Bitmap_CopyBlock(srcX, srcY, dstX * 16, dstY * 16, src, &terrainBmp, 16); + Bitmap_UNSAFE_CopyBlock(srcX, srcY, dstX * 16, dstY * 16, src, &terrainBmp, 16); } static ReturnCode TexPatcher_Terrain(struct Stream* s) { diff --git a/src/TexturePack.c b/src/TexturePack.c index 8d5b4bed8..009963f05 100644 --- a/src/TexturePack.c +++ b/src/TexturePack.c @@ -250,7 +250,7 @@ static void Animations_Draw(struct AnimationData* data, TextureLoc texLoc, int s #endif } else { srcX = data->FrameX + data->State * size; - Bitmap_CopyBlock(srcX, data->FrameY, 0, 0, &anims_bmp, &frame, size); + Bitmap_UNSAFE_CopyBlock(srcX, data->FrameY, 0, 0, &anims_bmp, &frame, size); } tex = Atlas1D.TexIds[dstX]; @@ -439,7 +439,7 @@ static void Atlas_Convert2DTo1D(void) { atlasX = Atlas2D_TileX(tile) * tileSize; atlasY = Atlas2D_TileY(tile) * tileSize; - Bitmap_CopyBlock(atlasX, atlasY, 0, y * tileSize, + Bitmap_UNSAFE_CopyBlock(atlasX, atlasY, 0, y * tileSize, &Atlas2D.Bmp, &atlas1D, tileSize); } Atlas1D.TexIds[i] = Gfx_CreateTexture(&atlas1D, true, Gfx.Mipmaps); @@ -477,7 +477,7 @@ static GfxResourceID Atlas_LoadTile_Raw(TextureLoc texLoc, Bitmap* element) { int x = Atlas2D_TileX(texLoc), y = Atlas2D_TileY(texLoc); if (y >= Atlas2D.RowsCount) return GFX_NULL; - Bitmap_CopyBlock(x * size, y * size, 0, 0, &Atlas2D.Bmp, element, size); + Bitmap_UNSAFE_CopyBlock(x * size, y * size, 0, 0, &Atlas2D.Bmp, element, size); return Gfx_CreateTexture(element, false, Gfx.Mipmaps); } diff --git a/src/Utils.c b/src/Utils.c index ec503c7d5..43eb4fd05 100644 --- a/src/Utils.c +++ b/src/Utils.c @@ -221,7 +221,7 @@ void EntryList_Load(struct EntryList* list, EntryList_Filter filter) { ReturnCode res; String_InitArray(path, pathBuffer); - String_AppendConst(&path, list->Path); + String_AppendConst(&path, list->path); res = Stream_OpenFile(&stream, &path); if (res == ReturnCode_FileNotFound) return; @@ -247,11 +247,11 @@ void EntryList_Load(struct EntryList* list, EntryList_Filter filter) { /* If don't prevent this here, client aborts in StringsBuffer_Add */ if (entry.length > STRINGSBUFFER_LEN_MASK) { entry.length = 0; - String_Format1(&entry, "Skipping extremely long line in %c, file may have been corrupted", list->Path); + String_Format1(&entry, "Skipping extremely long line in %c, file may have been corrupted", list->path); Logger_WarnFunc(&entry); continue; } - String_UNSAFE_Separate(&entry, list->Separator, &key, &value); + String_UNSAFE_Separate(&entry, list->separator, &key, &value); EntryList_Set(list, &key, &value); } @@ -266,13 +266,13 @@ void EntryList_Save(struct EntryList* list) { ReturnCode res; String_InitArray(path, pathBuffer); - String_AppendConst(&path, list->Path); + String_AppendConst(&path, list->path); res = Stream_CreateFile(&stream, &path); if (res) { Logger_Warn2(res, "creating", &path); return; } - for (i = 0; i < list->Entries.count; i++) { - entry = StringsBuffer_UNSAFE_Get(&list->Entries, i); + for (i = 0; i < list->entries.count; i++) { + entry = StringsBuffer_UNSAFE_Get(&list->entries, i); res = Stream_WriteLine(&stream, &entry); if (res) { Logger_Warn2(res, "writing to", &path); break; } } @@ -283,7 +283,7 @@ void EntryList_Save(struct EntryList* list) { int EntryList_Remove(struct EntryList* list, const String* key) { int i = EntryList_Find(list, key); - if (i >= 0) StringsBuffer_Remove(&list->Entries, i); + if (i >= 0) StringsBuffer_Remove(&list->entries, i); return i; } @@ -292,22 +292,22 @@ void EntryList_Set(struct EntryList* list, const String* key, const String* valu String_InitArray(entry, entryBuffer); if (value->length) { - String_Format3(&entry, "%s%r%s", key, &list->Separator, value); + String_Format3(&entry, "%s%r%s", key, &list->separator, value); } else { String_Copy(&entry, key); } EntryList_Remove(list, key); - StringsBuffer_Add(&list->Entries, &entry); + StringsBuffer_Add(&list->entries, &entry); } String EntryList_UNSAFE_Get(struct EntryList* list, const String* key) { String curEntry, curKey, curValue; int i; - for (i = 0; i < list->Entries.count; i++) { - curEntry = StringsBuffer_UNSAFE_Get(&list->Entries, i); - String_UNSAFE_Separate(&curEntry, list->Separator, &curKey, &curValue); + for (i = 0; i < list->entries.count; i++) { + curEntry = StringsBuffer_UNSAFE_Get(&list->entries, i); + String_UNSAFE_Separate(&curEntry, list->separator, &curKey, &curValue); if (String_CaselessEquals(key, &curKey)) return curValue; } @@ -318,9 +318,9 @@ int EntryList_Find(struct EntryList* list, const String* key) { String curEntry, curKey, curValue; int i; - for (i = 0; i < list->Entries.count; i++) { - curEntry = StringsBuffer_UNSAFE_Get(&list->Entries, i); - String_UNSAFE_Separate(&curEntry, list->Separator, &curKey, &curValue); + for (i = 0; i < list->entries.count; i++) { + curEntry = StringsBuffer_UNSAFE_Get(&list->entries, i); + String_UNSAFE_Separate(&curEntry, list->separator, &curKey, &curValue); if (String_CaselessEquals(key, &curKey)) return i; } @@ -328,7 +328,7 @@ int EntryList_Find(struct EntryList* list, const String* key) { } void EntryList_Init(struct EntryList* list, const char* path, char separator) { - list->Path = path; - list->Separator = separator; + list->path = path; + list->separator = separator; EntryList_Load(list, NULL); } diff --git a/src/Utils.h b/src/Utils.h index 3dc471d4a..22b61ca21 100644 --- a/src/Utils.h +++ b/src/Utils.h @@ -55,9 +55,9 @@ int Convert_ToBase64(const uint8_t* src, int len, char* dst); int Convert_FromBase64(const char* src, int len, uint8_t* dst); struct EntryList { - const char* Path; - char Separator; - StringsBuffer Entries; + const char* path; + char separator; + StringsBuffer entries; }; typedef bool (*EntryList_Filter)(const String* entry); diff --git a/src/Window.c b/src/Window.c index 56ff2ffdd..ee1fb40a3 100644 --- a/src/Window.c +++ b/src/Window.c @@ -2792,7 +2792,23 @@ static int32_t Window_HandleInputEvent(struct android_app* app, AInputEvent* ev) /* TODO: Do something with input here.. */ int32_t type = AInputEvent_getType(ev); Platform_Log1("INP MSG: %i", &type); - return 0; + switch (type) { + case AINPUT_EVENT_TYPE_MOTION: + { + /* TODO Fix this */ + int x = (int)AMotionEvent_getX(ev, 0); + int y = (int)AMotionEvent_getY(ev, 0); + + Platform_Log2("TOUCH: %i,%i", &x, &y); + Mouse_SetPosition(x, y); + + int action = AMotionEvent_getAction(ev) & AMOTION_EVENT_ACTION_MASK; + if (action == AMOTION_EVENT_ACTION_DOWN) Mouse_SetPressed(MOUSE_LEFT, true); + if (action == AMOTION_EVENT_ACTION_UP) Mouse_SetPressed(MOUSE_LEFT, false); + return 0; + } + } + return 1; } static void Window_HandleAppEvent(struct android_app* app, int32_t cmd) {