void TraceInfo(int session_id,char *class_name,int message_id,int num_parms, parm_node parms[]) { int i; val_type val; SendSessionAdminText(session_id,"%-15s%-20s ",class_name,GetNameByID(message_id)); for (i=0;i<num_parms;i++) { SendSessionAdminText(session_id,"%s = ",GetNameByID(parms[i].name_id)); val.int_val = parms[i].value; SendSessionAdminText(session_id,"%s ",GetTagName(val)); SendSessionAdminText(session_id,"%s",GetDataName(val)); if (i != num_parms-1) SendSessionAdminText(session_id,", "); } SendSessionAdminText(session_id,"\n"); }
void GameDMCommand(session_node *s,int type,char *str) { char buf[LEN_MAX_CLIENT_MSG + 200]; int acctype; acctype = ACCOUNT_NORMAL; if (s && s->account) acctype = s->account->type; // dprintf("DM command %i by session %i account %i acctype %i; string is \"%s\".\n", // type, s->session_id, s->account->account_id, acctype, str); switch (type) { case DM_CMD_GO_ROOM : if (0 != atoi(str)) { //ASSERT(0 != ACCOUNT_ADMIN); //ASSERT(0 != ACCOUNT_DM); if (ConfigInt(RIGHTS_GOROOMBYNUM) == 0) { dprintf("DM Command GOROOM (by number) disabled."); break; } if (ConfigInt(RIGHTS_GOROOMBYNUM) == ACCOUNT_ADMIN && acctype == ACCOUNT_DM) { dprintf("DM Command GOROOM (by number) disabled for DMs; must be Admin."); break; } } if (ConfigInt(RIGHTS_GOROOM) == 0) { dprintf("DM Command GOROOM disabled."); break; } if (ConfigInt(RIGHTS_GOROOM) == ACCOUNT_ADMIN && acctype == ACCOUNT_DM) { dprintf("DM Command GOROOM disabled for DMs; must be Admin."); break; } sprintf(buf,"send object %i teleportto rid int %s",s->game->object_id,str); SendSessionAdminText(s->session_id,"~B> %s\n",buf); /* echo it to 'em */ TryAdminCommand(s->session_id,buf); break; case DM_CMD_GO_PLAYER : if (ConfigInt(RIGHTS_GOPLAYER) == 0) break; if (ConfigInt(RIGHTS_GOPLAYER) == ACCOUNT_ADMIN && acctype == ACCOUNT_DM) break; sprintf(buf,"send object %i admingotoobject what object %s",s->game->object_id,str); SendSessionAdminText(s->session_id,"~B> %s\n",buf); /* echo it to 'em */ TryAdminCommand(s->session_id,buf); break; case DM_CMD_GET_PLAYER : if (ConfigInt(RIGHTS_GETPLAYER) == 0) break; if (ConfigInt(RIGHTS_GETPLAYER) == ACCOUNT_ADMIN && acctype == ACCOUNT_DM) break; sprintf(buf,"send object %s admingotoobject what object %i",str,s->game->object_id); SendSessionAdminText(s->session_id,"~B> %s\n",buf); /* echo it to 'em */ TryAdminCommand(s->session_id,buf); break; default : eprintf("GameDMCommand got invalid DM command type %i\n",type); break; } }
void GameProtocolParse(session_node *s,client_msg *msg) { user_node *u; int object_id; char *ptr; char password[MAX_LOGIN_PASSWORD+1],new_password[MAX_LOGIN_PASSWORD+1]; int len,index; char admin_cmd[500]; int admin_len; int dm_type; GameMessageCount((unsigned char)msg->data[0]); switch ((unsigned char)msg->data[0]) { case BP_REQ_QUIT : GameClientExit(s); SetSessionState(s,STATE_SYNCHED); break; case BP_RESYNC : // dprintf("client said it had an error\n"); GameSyncInit(s); GameSyncProcessSessionBuffer(s); break; case BP_PING : GameEchoPing(s); break; case BP_AD_SELECTED : /* they clicked on an ad; log it */ switch (msg->data[1]) { case 1: ptr = LockConfigStr(ADVERTISE_URL1); lprintf("GameProtocolParse found account %i visited ad 1, %s\n",s->account->account_id, ptr); UnlockConfigStr(); break; case 2: ptr = LockConfigStr(ADVERTISE_URL2); lprintf("GameProtocolParse found account %i visited ad 2, %s\n",s->account->account_id, ptr); UnlockConfigStr(); break; default : eprintf("GameProtocolParse found account %i visited unknown ad %i\n", s->account->account_id,msg->data[1]); } break; case BP_USE_CHARACTER : if (s->game->object_id == INVALID_OBJECT) { object_id = *((int *)(msg->data+1)); u = GetUserByObjectID(object_id); if (u != NULL && u->account_id == s->account->account_id) GameStartUser(s,u); else eprintf("GameProtocolParse can't find user for obj %i in use char!!!\n", object_id); InterfaceUpdateSession(s); } break; case BP_REQ_ADMIN : if (s->account->type != ACCOUNT_ADMIN) { eprintf("GameProtocolParse got admin command from non admin account %i\n", s->account->account_id); break; } admin_len = (int) * ((short *)(msg->data + 1)); if (admin_len > msg->len - 3) return; if (admin_len > sizeof(admin_cmd)-2) return; memcpy(admin_cmd,&msg->data[3],admin_len); admin_cmd[admin_len] = 0; SendSessionAdminText(s->session_id,"> %s\n",admin_cmd); /* echo it to 'em */ TryAdminCommand(s->session_id,admin_cmd); break; case BP_REQ_DM : if (s->account->type != ACCOUNT_ADMIN && s->account->type != ACCOUNT_DM) { eprintf("GameProtocolParse got DM command from non admin or DM account %i\n", s->account->account_id); break; } dm_type = msg->data[1]; admin_len = (int) * ((short *)(msg->data + 2)); if (admin_len > msg->len - 4) return; if (admin_len > sizeof(admin_cmd)-2) return; memcpy(admin_cmd,&msg->data[4],admin_len); admin_cmd[admin_len] = 0; GameDMCommand(s,dm_type,admin_cmd); break; case BP_SEND_CHARACTERS : GameTryGetUser(s); break; case BP_CHANGE_PASSWORD : index = 1; len = *(short *)(msg->data+index); if (index + 2 + len > msg->len) /* 2 = length word len */ break; if (len-1 > sizeof(password)) break; memcpy(password,msg->data+index+2,len); password[len] = 0; /* null terminate string */ index += 2 + len; len = *(short *)(msg->data+index); if (index + 2 + len > msg->len) break; if (len-1 > sizeof(new_password)) break; memcpy(new_password,msg->data+index+2,len); new_password[len] = 0; /* null terminate string */ index += 2 + len; if (strcmp(s->account->password,password)) { AddByteToPacket(BP_PASSWORD_NOT_OK); SendPacket(s->session_id); break; } SetAccountPasswordAlreadyEncrypted(s->account,new_password); AddByteToPacket(BP_PASSWORD_OK); SendPacket(s->session_id); break; default : ClientToBlakodUser(s,msg->len,msg->data); break; } }