void Creature::load(const Aurora::GFF3Struct &creature) { Common::UString temp = creature.getString("ResRef"); if (!temp.empty()) { try { Common::ScopedPtr<Aurora::GFF3File> cre(new Aurora::GFF3File(temp, Aurora::kFileTypeCRE, MKTAG('C', 'R', 'E', ' '))); loadBlueprint(cre->getTopLevel()); } catch (Common::Exception &e) { e.add("Creature \"%s\" has no blueprint", temp.c_str()); throw; } } // Tag _tag = creature.getString("Tag"); // Appearance if (_appearance == Aurora::kFieldIDInvalid) throw Common::Exception("Creature without an appearance"); loadAppearance(); loadInstance(creature); }
sys_shlfunc() #define sys_shl sys_shlfunc() {register int st,i,v ; st=cre(1); fprintf ( bstdout, "Shell (0 to quit): "); read_str(st); while( len_str(st)==0 ){ fprintf ( bstdout, "\n"); fprintf ( bstdout, "Shell (0 to quit): "); read_str(st); } while( fst_str(st)!=ord('0') ){ itr_str(st,i,v,cstr_shl[i-1]=chr(v)); cstr_shl[len_str(st)]='\0'; fprintf ( bstdout, "\n"); system(cstr_shl); fprintf ( bstdout, "\n"); fprintf ( bstdout, "Shell (0 to quit): "); read_str(st); while( len_str(st)==0 ){ fprintf ( bstdout, "\n"); fprintf ( bstdout, "Shell (0 to quit): "); read_str(st); } } }
void * clientHandler(void * arg) { threadStruct *inArg = (threadStruct *) arg; int sockfd = inArg->sockfd; free(inArg); char *msg = malloc(sizeof(char)*CMD_MAX_SIZE); *msg = '\0'; msgHeader header; User user; // Agregar usuario readBytes(sockfd, (void *) &header,sizeof(header)); readBytes(sockfd, (void *) msg, header.msgSize); cleanString(msg); user.sockfd = sockfd; strncpy(user.name,msg,NAMES_SIZE); *(user.name + NAMES_SIZE -1) = '\0'; list_append(&Users,(void *) &user); // Agregar a la sala default #! while (1) { // Leer un mensaje del cliente readBytes(sockfd, (void *) &header,sizeof(header)); readBytes(sockfd, (void *) msg, header.msgSize); cleanString(msg); switch (header.code) { case MSG_CODE_SHUT: break; // #! NOT DONE case MSG_CODE_SAL: sal(sockfd); break; case MSG_CODE_USU: usu(sockfd); break; case MSG_CODE_MEN: men(sockfd,msg); break; case MSG_CODE_SUS: sus(sockfd,msg); break; case MSG_CODE_DES: des(sockfd); break; case MSG_CODE_CRE: cre(sockfd,msg); break; case MSG_CODE_ELI: // eli() #! break; case MSG_CODE_FUE: fue(sockfd); free(msg); pthread_exit(NULL); break; } *msg = '\0'; } return NULL; }
bool addSingleCreatureConfig( TiXmlElement* elemCreature, vector<vector<CreatureConfiguration>*>& knownCreatures, int basefile ){ int gameID = lookupIndexedType(elemCreature->Attribute("gameID"),contentLoader.creatureNameStrings); if (gameID == INVALID_INDEX) return false; const char* sheetIndexStr; t_SpriteWithOffset sprite; sprite.fileIndex=basefile; sprite.x=0; sprite.y=0; sprite.animFrames=ALL_FRAMES; int baseShadow = DEFAULT_SHADOW; const char* shadowStr = elemCreature->Attribute("shadow"); if (shadowStr != NULL && shadowStr[0] != 0) { baseShadow = atoi( shadowStr ); } if (baseShadow < 0 || baseShadow > MAX_SHADOW) baseShadow = DEFAULT_SHADOW; const char* filename = elemCreature->Attribute("file"); if (filename != NULL && filename[0] != 0) { sprite.fileIndex = loadConfigImgFile((char*)filename,elemCreature); } TiXmlElement* elemVariant = elemCreature->FirstChildElement("variant"); while( elemVariant ){ int professionID = INVALID_INDEX; const char* profStr = elemVariant->Attribute("prof"); if (profStr == NULL || profStr[0] == 0) { profStr = elemVariant->Attribute("profession"); } professionID = translateProfession(profStr); const char* customStr = elemVariant->Attribute("custom"); if (customStr != NULL && customStr[0] == 0) { customStr = NULL; } if (customStr != NULL) { WriteErr("custom: %s\n",customStr); } const char* sexstr = elemVariant->Attribute("sex"); sheetIndexStr = elemVariant->Attribute("sheetIndex"); enumCreatureSex cresex = eCreatureSex_NA; if(sexstr){ if(strcmp( sexstr, "M" ) == 0) cresex = eCreatureSex_Male; if(strcmp( sexstr, "F" ) == 0) cresex = eCreatureSex_Female; } const char* specstr = elemVariant->Attribute("special"); enumCreatureSpecialCases crespec = eCSC_Any; if (specstr) { if(strcmp( specstr, "Normal" ) == 0) crespec = eCSC_Normal; if(strcmp( specstr, "Zombie" ) == 0) crespec = eCSC_Zombie; if(strcmp( specstr, "Skeleton" ) == 0) crespec = eCSC_Skeleton; } sprite.animFrames = getAnimFrames(elemVariant->Attribute("frames")); if (sprite.animFrames == 0) sprite.animFrames = ALL_FRAMES; int shadow = baseShadow; const char* shadowStr = elemVariant->Attribute("shadow"); if (shadowStr != NULL && shadowStr[0] != 0) { shadow = atoi( shadowStr ); } if (shadow < 0 || shadow > MAX_SHADOW) shadow = baseShadow; //create profession config sprite.sheetIndex=atoi(sheetIndexStr); CreatureConfiguration cre( professionID, customStr , cresex, crespec, sprite, shadow); //add a copy to known creatures pushCreatureConfig(knownCreatures, gameID, cre); elemVariant = elemVariant->NextSiblingElement("variant"); } //create default config baseShadow; sheetIndexStr = elemCreature->Attribute("sheetIndex"); sprite.animFrames = ALL_FRAMES; if (sheetIndexStr) { sprite.sheetIndex = atoi( sheetIndexStr ); CreatureConfiguration cre( INVALID_INDEX, NULL, eCreatureSex_NA, eCSC_Any, sprite, baseShadow); //add a copy to known creatures pushCreatureConfig(knownCreatures, gameID, cre); } return true; }
void patientView::createCR(){ int out = pID; emit cre(out, this); }
void *connection_handler(void *td) { int sock = ((Thread_data *) td)->client_sock; list subscribed_rooms = ((Thread_data *) td)->subscribed_rooms; char msg[MAX_PACK_SIZE]; memset(msg, 0, MAX_PACK_SIZE); user_data *user = wait_username(rooms, sock); user->subscribed_rooms = subscribed_rooms; add(connected_users, user); add(subscribed_rooms, rooms->first); int read_size; while ((read_size = recv(sock, msg, MAX_PACK_SIZE, 0)) > 0) { pthread_mutex_lock(&mutex); if (read_size < 3) { } else if ((strlen(msg) >= 6) && (msg[3] == ' ') && (msg[0] == 's') && (msg[1] == 'u') && (msg[2] == 's')) { memmove(msg, msg+4, 252); msg[strlen(msg)-1] = '\0'; //replace new line sus(msg, user); } else if ((strlen(msg) == 4) && (msg[0] == 's') && (msg[1] == 'a') && (msg[2] == 'l')) { sal(sock); } else if ((strlen(msg) >= 6) && //because of new line (msg[3] == ' ') && (msg[0] == 'm') && (msg[1] == 'e') && (msg[2] == 'n')) { memmove(msg, msg+4, 252); msg[strlen(msg)-1] = '\0'; //replace new line men(user, subscribed_rooms, msg); } else if ((strlen(msg) == 4) && (msg[0] == 'u') && (msg[1] == 's') && (msg[2] == 'u')) { usu(sock); } else if ((strlen(msg) == 4) && (msg[0] == 'd') && (msg[1] == 'e') && (msg[2] == 's')) { des(subscribed_rooms, user); } else if ((strlen(msg) >= 6) && (msg[3] == ' ') && (msg[0] == 'c') && (msg[1] == 'r') && (msg[2] == 'e')) { memmove(msg, msg+4, 252); msg[strlen(msg)-1] = '\0'; //replace new line cre(sock, msg); } else if ((strlen(msg) >= 6) && (msg[3] == ' ') && (msg[0] == 'e') && (msg[1] == 'l') && (msg[2] == 'i')) { memmove(msg, msg+4, 252); msg[strlen(msg)-1] = '\0'; //replace new line eli(msg, sock, user); } else if ((strlen(msg) == 4) && (msg[0] == 'f') && (msg[1] == 'u') && (msg[2] == 'e')) { fue(subscribed_rooms, user); } else if ((strlen(msg) == 4) && (msg[0] == 'h') && (msg[1] == 'l') && (msg[2] == 'p')) { memset(msg, 0, MAX_PACK_SIZE); strcat(msg, "-----------\n"); strcat(msg, "The valids commands formats are:\n"); strcat(msg, "sus <room name>\n"); strcat(msg, "cre <room name>\n"); strcat(msg, "eli <room name>\n"); strcat(msg, "sal\n"); strcat(msg, "usu\n"); strcat(msg, "des\n"); strcat(msg, "fue\n"); strcat(msg, "-----------"); write(sock, msg, MAX_PACK_SIZE); } else { memset(msg, 0, MAX_PACK_SIZE); strcat(msg, "Unrecognized option."); strcat(msg, " Try `hlp' for more information."); write(sock, msg, MAX_PACK_SIZE); } memset(msg, 0, MAX_PACK_SIZE); pthread_mutex_unlock(&mutex); } }