Jeck - Please review.

Disconcertingly enough, this seems to resolve issue 109. Ran demo mode for 1 hour (w00t no crashes!), played five manual games, shop appeared fine... but why would an mObject ever be null? I'm not so sure about this commit. It "fixes" the issue, but doesn't do anything for the underlying cause. For all I know, I might just not have re-encountered issue 109 yet... still, it's not a /bad/ commit. In the worst case, it does some unnecessary sanity checking. There's potential for a a hang if item is NULL in Update(), if input doesn't get passed along in a way that allows the player to exit... But I think that's what the call to JGuiController::Update is for.

Thoughts?
This commit is contained in:
wagic.jeck
2009-10-26 02:27:55 +00:00
parent 2d49747da9
commit 8a6162ba15

View File

@@ -248,17 +248,21 @@ void ShopItems::Update(float dt){
}else{
if (showPriceDialog!=-1){
ShopItem * item = ((ShopItem *)mObjects[showPriceDialog]);
int price = item->price;
char buffer[4096];
sprintf(buffer,"%s : %i credits",item->getText(),price);
if(!dialog){
dialog = NEW SimpleMenu(1,this,resources.GetJLBFont(Constants::MENU_FONT),SCREEN_WIDTH-300,SCREEN_HEIGHT/2,buffer);
dialog->Add(1,"Yes");
dialog->Add(2,"No");
}
else{
dialog->Update(dt);
if(item){
int price = item->price;
char buffer[4096];
sprintf(buffer,"%s : %i credits",item->getText(),price);
if(!dialog){
dialog = NEW SimpleMenu(1,this,resources.GetJLBFont(Constants::MENU_FONT),SCREEN_WIDTH-300,SCREEN_HEIGHT/2,buffer);
dialog->Add(1,"Yes");
dialog->Add(2,"No");
}
else{
dialog->Update(dt);
}
}
else
JGuiController::Update(dt);
}else{
u32 buttons[] = {PSP_CTRL_LEFT,PSP_CTRL_DOWN,PSP_CTRL_RIGHT,PSP_CTRL_UP,PSP_CTRL_CIRCLE};
for (int i = 0; i < 5; ++i){
@@ -313,7 +317,8 @@ void ShopItems::Render(){
if(mCurr >= 0){
mFont->SetColor(ARGB(255,255,255,0));
ShopItem * item = ((ShopItem *)mObjects[mCurr]);
mFont->DrawString(item->mText.c_str(), SCREEN_WIDTH/2 - 50, SCREEN_HEIGHT - 14,JGETEXT_CENTER);
if(item)
mFont->DrawString(item->mText.c_str(), SCREEN_WIDTH/2 - 50, SCREEN_HEIGHT - 14,JGETEXT_CENTER);
mFont->SetColor(ARGB(255,255,255,255));
}
@@ -326,7 +331,7 @@ void ShopItems::Render(){
if (i == mCurr) mFont->SetColor(ARGB(255,255,255,0));
else mFont->SetColor(ARGB(255,255,255,255));
char buffer[512];
sprintf(buffer, "%s", s->getText());
sprintf(buffer, "%s", s ? s->getText() : "error");
float x = 300;
float y = 10 + 20*i;
mFont->DrawString(buffer,x,y);