bool CIwGameFile::GetFileType(const char* file_path, CIwGameString& type) { int len = strlen(file_path) - 1; const char* name_ptr = file_path + len; // Scan backwards looking for dot int index = 0; while (len >= 0) { if (*name_ptr == '.') { type.setString(name_ptr + 1, index); type.ToLower(); break; } else if (len == 0) { type.setString(name_ptr, index + 1); type.ToLower(); break; } name_ptr--; index++; len--; } return true; }
// // // // // CIwGameCommandIfVar Implementation // // // // bool CIwGameCommandIfVar::Execute(float dt) { if (!IIwGameCommandExecutor::Execute(dt)) return false; CIwGame* game = NULL; CIwGameScene* scene = NULL; CIwGameActor* actor = NULL; unsigned int class_hash = Program->getManager()->getParent()->getClassTypeHash(); if (class_hash == CIwGameXomlNames::Game_Hash) game = (CIwGame*)Program->getManager()->getParent(); else if (class_hash == CIwGameXomlNames::Scene_Hash) scene = (CIwGameScene*)Program->getManager()->getParent(); if (game != NULL) scene = game->findScene(Params[3].getHash()); IIwGameXomlResource* cont = (actor != NULL) ? (IIwGameXomlResource*)actor : (IIwGameXomlResource*)scene; CIwGameXomlVariable* var = CIwGameXomlVariable::GetVariable(Params[0], scene); if (var != NULL) { CIwGameString op = getParameter2(cont); op.ToLower(); if (op == "==") ReturnValue = (int)var->checkCondition(CO_Equal, getParameter3(cont)); else if (op == "!=") ReturnValue = (int)var->checkCondition(CO_NotEqual, getParameter3(cont)); else if (op == "gt") ReturnValue = (int)var->checkCondition(CO_Greater, getParameter3(cont)); else if (op == "lt") ReturnValue = (int)var->checkCondition(CO_Less, getParameter3(cont)); else if (op == "gte") ReturnValue = (int)var->checkCondition(CO_GreaterEqual, getParameter3(cont)); else if (op == "lte") ReturnValue = (int)var->checkCondition(CO_LessEqual, getParameter3(cont)); else if (op == "and") ReturnValue = (int)var->checkCondition(CO_And, getParameter3(cont)); else CIwGameError::LogError("Warning: IfVar command - operator invalid - ", op.c_str()); } else CIwGameError::LogError("Warning: IfVar command - variable not found - ", Params[0].c_str()); return false; }
// // // // ImMobi specific implementation // // // bool CIwGameAds::RequestAdInMobi() { // Build M2M request URI string RequestURI = "http://w.inmobi.com/showad.asm"; // Live // RequestURI = "http://i.w.sandbox.inmobi.com/showad.asm"; // Test int slotSize = (int)SlotSize; CIwGameString body; CIwGameString urlencoded; body = "mk-siteid="; body += ApplicationID; body += "&mk-carrier="; body += IW_GAME_HTTP_MANAGER->getIPAddress(); body += "&h-user-agent="; urlencoded.URLEncode(UserAgent.c_str()); urlencoded.ToLower(); body += urlencoded; body += "&u-id="; body += CIwGameString(UDID); body += "&d-localization="; urlencoded.URLEncode(s3eDeviceGetString(S3E_DEVICE_LOCALE)); urlencoded.ToLower(); body += urlencoded; // body += "&d-netType=wifi"; body += "&d-netType=carrier"; body += "&mk-ad-slot="; body += CIwGameString(slotSize); body += "&mk-version=pr-SPEC-CTATA-20130111"; if (UserAge != 0) { body += "&u-age="; body += CIwGameString(UserAge); } if (UserGender != GenderInvalid) { if (UserGender == GenderFemale) body += "&u-gender=f"; else body += "&u-gender=m"; } if (!UserGPSLocation.IsEmpty()) { body += "&u-latlong="; body += UserGPSLocation; } if (!UserKeywords.IsEmpty()) { body += "&u-interests="; body += UserKeywords; } if (!ExtraInfo.IsEmpty()) { body += ExtraInfo; } // body.ToLower(); AdRequest.setPOST(); AdRequest.setURI(RequestURI.c_str()); AdRequest.setContentAvailableCallback(&AdInfoRetrievedCallback, NULL); AdRequest.SetHeader("User-Agent", UserAgent.c_str()); AdRequest.SetHeader("X-Mkhoj-SiteID", ApplicationID.c_str()); AdRequest.SetHeader("Content-Type", "application/x-www-form-urlencoded"); AdRequest.SetHeader("Content-Length", CIwGameString(body.GetLength()).c_str()); AdRequest.setBody(body.c_str()); IW_GAME_HTTP_MANAGER->AddRequest(&AdRequest); BusyTimer.setDuration(IW_GAME_ADS_TIMEOUT); return true; }