Cocos2d unsigned int showing up everywhere - cocos2d-iphone

I'm not sure what I did - I was coding away merrily.. I think it might have something to do with updating Xcode to 4.1.1, but all of a sudden, when I build and run my project, the following compiler warning shows up in about 20 different cocos2d modules..
'format specifies unsigned int but the argument has ['CCTimer'] (or whatever module it's in)
the line in question in the cocos2d module is:
return [NSString stringWithFormat:#"<%# = %08X | target:%# selector:(%#)>", [self class], self, [target class], NSStringFromSelector(selector)];
and it's the '%08X' that's causing the problem..
And since this error, I can't compile on my iphone, although it runs fine in the simulator. I updated my phone OS to the latest, but it didn't help..
Has anyone else had this?

That's one of many format strings in cocos2d trying to print out the pointer value. While %08X works the correct way to do this is to use %p. So you can change the line to this:
[NSString stringWithFormat:#"<%# = %p | target:%# selector:(%#)>", [self class], self, [target class], NSStringFromSelector(selector)];
You will have to change all these lines, there's about a dozen or so of them.
Example output for anyone curious what the difference looks like:
%08X: 0976DC80
%p: 0x976dc80
PS: I have recently fixed all these incorrect cocos2d logs in Kobold2D.

Related

SDL2 ios How to get UIViewController pointer

I'm making a mobile game with SDL2 which will be initially developed for IOS.
I have almost finnished the game development, and now, in order to integrate it with Firebase, I need a pointer to UIViewController.
After reading countless topics, I tried this:
SDL_SysWMinfo systemWindowInfo;
SDL_VERSION (& systemWindowInfo.version);
SDL_GetWindowWMInfo (sdlWindow, & systemWindowInfo))
UIWindow * appWindow = mainWindowWMInfo.info.uikit.window;
UIViewController * rootViewController = appWindow.rootViewController;
But the line "UIViewController * rootViewController = appWindow.rootViewController;" causes this error: "Incomplete definition of type '_UIWindow'"
All topics related to this sample code are at least four years old, and I'm trying hard, but I haven't found any topics talking recently about how to get UIViewController in an SDL2 / ios project.
So, my questions are:
Is the sample code above still working in the current versions of SDL2 or has something changed in the latest version and this sample code no longer works?
If the sample code still works, what can I do wrong to cause this “Incomplete definition of type '_UIWindow'” error?
If this sample code no longer works in SDL2, how can I get a UIViewController pointer in the current version of SDL2?
Any help is welcome because I have been stuck in this problem for days. I've been working on this game for ten months and solving this problem is the last task left to complete it , so I really need to solve this issue.
I solve this problem. Everything is OK in SDL, I was using a .cpp file in this code, but I needed to use .mm file here.
So, when I switched the file name from cpp to mm, the problem has solved.

Warning after initializing particle effects in Cocos2dx - "libpng warning: iCCP: known incorrect sRGB profile"

I am trying to load particle effects (in .plist format) in my Cocos2d-x game code, and I am facing the warning: "libpng warning: iCCP: known incorrect sRGB profile", as mentioned in the question. I have done some research on my end, and the other StackOverflow users who asked similar questions had this issue while loading .png files.
However, I am facing the same issue while initializing .plist files instead. Any insight on how to remove this warning would be helpful. Kindly note that I am not facing any issue with loading the .plist file as such, but the warnings are polluting my log streams.
Sample code:
ParticleSystem* testStar = testNode->getChildByName<ParticleSystem*>("star");
testStar->initWithFile(filePath + "/" + "test.plist"); //valid filePath
testStar->setVisible(true);
Also, to confirm that this isn't an issue with the .plist file itself, I tried loading the file manually on my UI editor tool, and that seemed to load it without any issues.
I am ready to provide more details on my environment if necessary. I tried doing the above in a blank project as well, and I was able to reproduce the same warning.
Cocos2d-x version: cocos2d-x-3.14.1
I was able to solve this by using a sub-class of ParticleSystem instead of ParticleSystem itself. The sub-class I used is ParticleSystemQuad. Additionally, I realized that the initWithFile API was being called multiple times in my code, due to Cocos2D update schedulers. That may have been a cause for this warning.
To fix this warning, I created a fresh variable/system, and assigned a parent to it, while setting the position of the new variable to that of a well-known (desired position) node.
/* Getting the desired particleEffect position */
const Vec2& desiredPos = testNode->getChildByName("blablablah")->getPosition();
std::string filePath = "/"; //assign a directory for the .plist
// Avoid exponentiation
if (!testNode->getChildByName("sampleParticle")) {
auto p1 = ParticleSystemQuad::create(filePath + "/" + "test.plist");
p1->setPosition(desiredPos);
p1->resetSystem();
p1->setName("sampleParticle");
p1->setVisible(true);
testNode->addChild(p1);
}

Swift 3 - AWS iOS 'EXC_BAD_INSTRUCTION' Error

After converting over to Swift 3, my AWS iOS App now crashes when being run.
Has anyone seen anything similar after converting over to Swift 3?
Its crashing because you are doing a few things here:
trying to return a method call (which I don't think is possible - but I've never tried it)
application: didFinishLaunching should only ever return true because it's a boolean function as the name suggests. So the return value should be true. If you'd like to override application: didFinishLaunching you can declare that later in your AppDelegate
So here's what you can do... Try deleting the method and slowly type it back until Xcode auto-completes it for you. That will allow you to see what has been depreciated, or what other methods might be useful, also if you haven't yet hit Command + Shift + K to run a clean on your project. Xcode 8 and Swift 3 might have altered a few more things you aren't aware of.
launchOptions is an optional parameter. Doing a forced unwrap with the ! will crash if the value is nil, which it usually is.

Compiling old C++ classes under Borland C++Builder XE

Currently, I'm working on compiling old .cpp classes under C++ Builder XE. Apart from many troubles, there is one which I have completely no idea how to solve.
My code:
String txt = "<Not so long sql query>";
int licz = some_function(txt, dzeFDS); //1
//assigning licz to somewhere
txt = "<much longer query>";
licz = some_function(txt, budFDS); //2
Problem is that during second call of some_function program is stopped and i have this alert:
First chance exception at $75A1C42D. Exception class EDatabaseError with message 'budFDS: Type mismatch for field 'Function', expecting: String actual: WideString'. Process Call.exe (1896)
It's strange form be, bacause first call of some_function works fine, but this second one (with arguments with the same type) doesn't.
some_function code:
int __fastcall some_function(String txt, TIBDataSet *firDS)
{
firDS->Close();
firDS->SelectSQL->Text = txt;
firDS->Open(); //during debugging, exception occurs in this line
int count = 0;
while(!firDS->Eof)
{ count++;
firDS->Next();
}
return count;
}
Any ideas what why it happens?
Thanks in advance
There is much pain in your future.
Anyway, the problem you're having is with the database connection. There's a field in your database called "Function" that holds a string. This field came across as a String with the ancient database driver that this program originally used. Your shiny, new database driver is telling VCL to expect such things as Unicode, and VCL doesn't like to shove such things into plain Strings, so it expects you to have a WideString ready in which to shove it.
Fortunately, there are ways of beating VCL into submission. What you want to do, since you surely don't want to rewrite half the application by changing TIBDataSet, is to tell the connection not to bother with Unicode. In order to do this, you have to set up the TSQLConnection object with UseUnicode=false, which I hope (I have no way of testing VCL code anymore) should look something like this:
connection->Params->Add("UseUnicode=false");
Where connection is the TSQLConnection object. I think you have to do this before connecting to the database.
If that doesn't work, see if you can configure the database driver to not use Unicode.
Problem solved - this one field Function has other type in C++ Builder design view - it was TStringField, and rest fields has TIBStringField...

Cocos2D iPhone Extensions v0.2.1: CCMenuAdvanced warning: CCMenu may not respond to initWithItems:vaList: Should I be concerned?

Looked in the CCMenu.h and it looks like it responds to the exact method Xcode (4.5.2) is saying it doesn't respond to. I've tried overriding the method and extending CCMenu, but it always throws the same message.
When I build and run my project, it seems to work fine. Should I ignore this warning and continue with my game? Another question: Is there a simple way to 'update' this code to a non-deprecated or outdated method? Here's the cocos2d-iphone-extensions version I'm using. Also, it's cocos2d 2.1.
The error is generated on line 76 of the .m file.
CCMenuAdvanced.h:
https://github.com/cocos2d/cocos2d-iphone-extensions/blob/master/Extensions/CCMenuAdvanced/CCMenuAdvanced.h
CCMenuAdvanced.m:
https://github.com/cocos2d/cocos2d-iphone-extensions/blob/master/Extensions/CCMenuAdvanced/CCMenuAdvanced.m
You are getting this warning because -(id) initWithItems: (CCMenuItem*) item vaList: (va_list) args is not present in the header file (CCMenuAdvanced.h).
You need to use + (id) menuWithItems: (CCMenuItem*) firstItem vaList: (va_list) args; from CCMenu (superclass of CCMenuAdvanced).