I get an error about "orphaned case". So this is the error. Can you help me on what I did wrong?

client.java: 8643: orphaned case
case 117: // bank 5 items - sell 1 item
^

This is the code:

case 117:	//bank 5 items - sell 1 item
interfaceID = inStream.readSignedWordBigEndianA();
removeID = inStream.readSignedWordBigEndianA();
removeSlot = inStream.readSignedWordBigEndian();

//println_debug("RemoveItem 5: "+removeID +" InterID: "+interfaceID +" slot: "+removeSlot );

if (interfaceID == 5064) { //remove from bag to bank
bankItem(removeID , removeSlot, 5);
} else if (interfaceID == 5382) { //remove from bank
fromBank(removeID , removeSlot, 5);
} else if (interfaceID == 3322) { //remove from bag to trade window
if(isUntradable(removeID))
sendMessage("You cannot trade this item"); 
else
tradeItem(removeID , removeSlot, 5);
} else if (interfaceID == 3415) { //remove from trade window
fromTrade(removeID, removeSlot, 5);
} else if (interfaceID == 3823) { //Show value to sell items
sellItem(removeID, removeSlot, 1);
} else if (interfaceID == 3900) { //Show value to buy items
buyItem(removeID, removeSlot, 1);
} 
break;

Recommended Answers

All 8 Replies

I get an error about "orphaned case". So this is the error. Can you help me on what I did wrong?

client.java: 8643: orphaned case
case 117: // bank 5 items - sell 1 item
^

This is the code:

case 117:	//bank 5 items - sell 1 item
interfaceID = inStream.readSignedWordBigEndianA();
removeID = inStream.readSignedWordBigEndianA();
removeSlot = inStream.readSignedWordBigEndian();

//println_debug("RemoveItem 5: "+removeID +" InterID: "+interfaceID +" slot: "+removeSlot );

if (interfaceID == 5064) { //remove from bag to bank
bankItem(removeID , removeSlot, 5);
} else if (interfaceID == 5382) { //remove from bank
fromBank(removeID , removeSlot, 5);
} else if (interfaceID == 3322) { //remove from bag to trade window
if(isUntradable(removeID))
sendMessage("You cannot trade this item"); 
else
tradeItem(removeID , removeSlot, 5);
} else if (interfaceID == 3415) { //remove from trade window
fromTrade(removeID, removeSlot, 5);
} else if (interfaceID == 3823) { //Show value to sell items
sellItem(removeID, removeSlot, 1);
} else if (interfaceID == 3900) { //Show value to buy items
buyItem(removeID, removeSlot, 1);
} 
break;

The "case" line must be part of a switch statement block of code. Is it? You may need to post the entire switch statement for us to help. I'm guessing that it is not currently part of a switch statement.

Yes it is, but the switch statement is huge I don't think it will can fit in this. But I will put the case before this one.

Case before case 117:

case 145: //remove item (opposite for wearing) - bank 1 item - value of item
interfaceID = inStream.readUnsignedWordA();
int removeSlot = inStream.readUnsignedWordA();
int removeID = inStream.readUnsignedWordA();

if (interfaceID == 1688) {
if (playerEquipment[removeSlot] == removeID) {
remove(removeID , removeSlot);
} else if (interfaceID == 5064) { //remove from bag to bank
bankItem(removeID , removeSlot, 1);
} else if (interfaceID == 5382) { //remove from bank
fromBank(removeID , removeSlot, 1);
} else if (interfaceID == 3322) { //remove from bag to trade window
if(removeID == 6556) {
sendMessage("You cannot trade this item.");
} else {
tradeItem(removeID , removeSlot, 1);
}
} else if (interfaceID == 3415) { //remove from trade window
fromTrade(removeID, removeSlot, 1);
} else if (interfaceID == 3823) { //Show value to sell items
if (Item.itemSellable[removeID] == false) {
sendMessage("I cannot sell "+GetItemName(removeID)+".");
} else {
boolean IsIn = false;
if (server.shopHandler.ShopSModifier[MyShopID] > 1) {
for (int j = 0; j <= server.shopHandler.ShopItemsStandard[MyShopID]; j++) {
if (removeID == (server.shopHandler.ShopItems[MyShopID][j] - 1)) {
IsIn = true;
break;
}
}
} else {
IsIn = true;
}
if (IsIn == false) {
sendMessage("You cannot sell "+GetItemName(removeID)+" in this store.");
} else {
int ShopValue = (int)Math.floor(GetItemShopValue(removeID, 1, removeSlot));
String ShopAdd = "";
if (ShopValue <= 1){
ShopValue = (int)Math.floor(GetItemShopValue(removeID, 0, removeSlot));
}
if (ShopValue >= 1000 && ShopValue < 1000000) {
ShopAdd = " (" + (ShopValue / 1000) + "K)";
} else if (ShopValue >= 1000000) {
ShopAdd = " (" + (ShopValue / 1000000) + " million)";
}
sendMessage(GetItemName(removeID)+": shop will buy for "+ShopValue+" PkCredits"+ShopAdd);
}
}
} else if (interfaceID == 3900) { //Show value to buy items
int ShopValue = (int)Math.floor(GetItemShopValue(removeID, 0, removeSlot));
String ShopAdd = "";
if (ShopValue <= 1){
ShopValue = (int)Math.floor(GetItemShopValue(removeID, 0, removeSlot));
}
if (ShopValue >= 1000 && ShopValue < 1000000) {
ShopAdd = " (" + (ShopValue / 1000) + "K)";
} else if (ShopValue >= 1000000) {
ShopAdd = " (" + (ShopValue / 1000000) + " million)";
}
sendMessage(GetItemName(removeID)+": currently costs "+ShopValue+" PkCredits"+ShopAdd);
}
break;

I'm guessing you have a brackets issue. Stick the code in an IDE that will format/indent for you, and hopefully also has a code folding option for the "if" statements. I'm guessing you have more beginning brackets than ending brackets or vice versa. I couldn't get NetBeans to do it, but another programming tool with code folding showed that there is no ending bracket to go along the the first if statement, if I was reading it correctly.

I don't get you.

I don't get you.

In the code you posted in post 3 for "case 145", count the number of opening brackets { and the number of closing brackets } and make sure you have the same number of each. If you have more of one than the other, that could be the cause of your problem.

Ah Ok I get you.

I found out that case 145 has more of { than }, but idk where to add the last }, If I just add it to the end of the code I get 100 errors. Case 117 is equal by { and }. So the problem is case 145. Can you find out where to add the final }?

Here's your code formatted better. Cut and paste it into an IDE like NetBeans. It'll look better. Either go through with a pencil and mark opening brackets with different numbers after printing it out, or put comments next to them in the IDE. When you see a closing bracket, write in the number of the opening bracket it goes with and make sure it's the right one. Your code is a prime candidate for either replacing a lot of the else statements with else if statements or having another switch statement. That'll reduce the number of nested if statements substantially.

If, while doing the above, you run into an "if" statement that tests for a variable that hasn't changed (i.e. interfaceID) within an "if" statement that tested that same variable before, chances are that's where your problem is.

case 145: //remove item (opposite for wearing) - bank 1 item - value of item
            interfaceID = inStream.readUnsignedWordA();
            int removeSlot = inStream.readUnsignedWordA();
            int removeID = inStream.readUnsignedWordA();

            if (interfaceID == 1688)
            {
               if (playerEquipment[removeSlot] == removeID)
               {
                  remove(removeID, removeSlot);
               }
               else
               {
                  if (interfaceID == 5064)
                  { //remove from bag to bank
                     bankItem(removeID, removeSlot, 1);
                  }
                  else
                  {
                     if (interfaceID == 5382)
                     { //remove from bank
                        fromBank(removeID, removeSlot, 1);
                     }
                     else
                     {
                        if (interfaceID == 3322)
                        { //remove from bag to trade window
                           if (removeID == 6556)
                           {
                              sendMessage("You cannot trade this item.");
                           }
                           else
                           {
                              tradeItem(removeID, removeSlot, 1);
                           }
                        }
                        else
                        {
                           if (interfaceID == 3415)
                           { //remove from trade window
                              fromTrade(removeID, removeSlot, 1);
                           }
                           else
                           {
                              if (interfaceID == 3823)
                              { //Show value to sell items
                                 if (Item.itemSellable[removeID] == false)
                                 {
                                    sendMessage("I cannot sell " + GetItemName(removeID) + ".");
                                 }
                                 else
                                 {
                                    boolean IsIn = false;
                                    if (server.shopHandler.ShopSModifier[MyShopID] > 1)
                                    {
                                       for (int j = 0; j <= server.shopHandler.ShopItemsStandard[MyShopID]; j++)
                                       {
                                          if (removeID == (server.shopHandler.ShopItems[MyShopID][j] - 1))
                                          {
                                             IsIn = true;
                                             break;
                                          }
                                       }
                                    }
                                    else
                                    {
                                       IsIn = true;
                                    }
                                    if (IsIn == false)
                                    {
                                       sendMessage("You cannot sell " + GetItemName(removeID) + " in this store.");
                                    }
                                    else
                                    {
                                       int ShopValue = (int) Math.floor(GetItemShopValue(removeID, 1, removeSlot));
                                       String ShopAdd = "";
                                       if (ShopValue <= 1)
                                       {
                                          ShopValue = (int) Math.floor(GetItemShopValue(removeID, 0, removeSlot));
                                       }
                                       if (ShopValue >= 1000 && ShopValue < 1000000)
                                       {
                                          ShopAdd = " (" + (ShopValue / 1000) + "K)";
                                       }
                                       else
                                       {
                                          if (ShopValue >= 1000000)
                                          {
                                             ShopAdd = " (" + (ShopValue / 1000000) + " million)";
                                          }
                                       }
                                       sendMessage(GetItemName(removeID) + ": shop will buy for " + ShopValue + " PkCredits" + ShopAdd);
                                    }
                                 }
                              }
                              else
                              {
                                 if (interfaceID == 3900)
                                 { //Show value to buy items
                                    int ShopValue = (int) Math.floor(GetItemShopValue(removeID, 0, removeSlot));
                                    String ShopAdd = "";
                                    if (ShopValue <= 1)
                                    {
                                       ShopValue = (int) Math.floor(GetItemShopValue(removeID, 0, removeSlot));
                                    }
                                    if (ShopValue >= 1000 && ShopValue < 1000000)
                                    {
                                       ShopAdd = " (" + (ShopValue / 1000) + "K)";
                                    }
                                    else
                                    {
                                       if (ShopValue >= 1000000)
                                       {
                                          ShopAdd = " (" + (ShopValue / 1000000) + " million)";
                                       }
                                    }
                                    sendMessage(GetItemName(removeID) + ": currently costs " + ShopValue + " PkCredits" + ShopAdd);
                                 }
                              }
                           }
                        }
                     }
                  }
               }
               break;

Again, paste this into an IDE so it'll look better than it does above (won't have the line wraparounds)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.