ACMD(do_cube)
{
if (!ch->CanDoCube())
return;
sys_log(1, "CUBE COMMAND <%s>: %s", ch->GetName(), argument);
int cube_index = 0, inven_index = 0;
const char *line;
char arg1[256], arg2[256], arg3[256];
line = two_arguments(argument, arg1, sizeof(arg1), arg2, sizeof(arg2));
one_argument(line, arg3, sizeof(arg3));
if (0 == arg1[0])
{
// print usage
ch->ChatPacket(CHAT_TYPE_INFO, "Usage: cube open");
ch->ChatPacket(CHAT_TYPE_INFO, " cube close");
ch->ChatPacket(CHAT_TYPE_INFO, " cube add <inveltory_index>");
ch->ChatPacket(CHAT_TYPE_INFO, " cube delete <cube_index>");
ch->ChatPacket(CHAT_TYPE_INFO, " cube list");
ch->ChatPacket(CHAT_TYPE_INFO, " cube cancel");
ch->ChatPacket(CHAT_TYPE_INFO, " cube make [all]");
return;
}
const std::string& strArg1 = std::string(arg1);
// r_info (request information)
// (Server -> Client) /cube r_list npcVNUM resultCOUNT 123,1/125,1/128,1/130,5
// (Server -> Client) /cube m_info startIndex count 125,1|126,2|127,2|123,5&555,5&555,4/120000@125,1|126,2|127,2|123,5&555,5&555,4/120000
if (strArg1 == "r_info")
{
if (0 == arg2[0])
Cube_request_result_list(ch);
else
{
if (isdigit(*arg2))
{
int listIndex = 0, requestCount = 1;
str_to_number(listIndex, arg2);
if (0 != arg3[0] && isdigit(*arg3))
str_to_number(requestCount, arg3);
Cube_request_material_info(ch, listIndex, requestCount);
}
}
return;
}
switch (LOWER(arg1[0]))
{
case 'o': // open
Cube_open(ch);
break;
case 'c': // close
Cube_close(ch);
break;
case 'l': // list
Cube_show_list(ch);
break;
case 'a': // add cue_index inven_index
{
if (0 == arg2[0] || !isdigit(*arg2) ||
0 == arg3[0] || !isdigit(*arg3))
return;
str_to_number(cube_index, arg2);
str_to_number(inven_index, arg3);
Cube_add_item (ch, cube_index, inven_index);
}
break;
case 'd': // delete
{
if (0 == arg2[0] || !isdigit(*arg2))
return;
str_to_number(cube_index, arg2);
Cube_delete_item (ch, cube_index);
}
break;
case 'm': // make
if (0 != arg2[0])
{
while (true == Cube_make(ch))
sys_log(1, "cube make success");
}
else
Cube_make(ch);
break;
default:
return;
}
}