void Opcode810C::_run() { int direction = _script->dataStack()->popInteger(); int animation = _script->dataStack()->popInteger(); auto object = static_cast<Game::Object*>(_script->dataStack()->popObject()); Logger::debug("SCRIPT") << "[810C] [*] void anim(GameCritterObject* who, int animation, int direction)" << std::endl << " direction = 0x" << std::hex << direction << std::endl << " animation = 0x" << std::hex << animation << std::endl; switch (animation) { case 1000: // ANIMATE_ROTATION. direction is orientation { object->setOrientation(direction); //critter->setActionAnimation("aa"); break; } case 1010: // ANIMATE_SET_FRAME. direction is frame number { _warning("op_anim - unimplemented ANIMATE_SET_FRAME"); break; } default: // set animation? direction is forward/backward { _warning("op_anim - unimplemented animation: " + std::to_string(animation)); break; } } }
static int receive_file(t_handle *handle, char *path, int size, t_msg *msg) { char *buf; int fd; if (!(buf = malloc(sizeof(char) * size))) return (_error("Can't allocate memory : %m\n", -1)); if ((fd = open(path, O_RDWR)) < 0) return (_warning("Can't open file : %m\n", -1)); if (read(fd, buf, size) < 0) return (_warning("Can't read file : %m\n", -1)); if (write(handle->cli_fd, buf, size) < 0) return (_error("Can't write on client %d: %m\n", -1, handle->cli_num)); if (server_read_sock(handle, buf) < 0) return (IWARNING); if (!strncmp(buf, "OK", 2)) add_log("File %s successfully send to client %d\n", 0, msg->arg , handle->cli_num); else add_log("Fail to send file %s to client %d\n", 0, msg->arg , handle->cli_num); free(buf); close(fd); return (ISUCCESS); }
/** * lw6snd_is_music_file * * @sys_context: global system context * @backend: sound backend to use * @map_dir: map directory, to search additionnal files * @music_path: config entry containing multiple paths * @music_file: relative/local name of a music file * * Tells wether a file is a valid music file, typicallly based on file * existence and extension. Not bullet proof, file might actually not * be loadable, but chances are 99%. * * Return value: 1 if music file, 0 if not */ int lw6snd_is_music_file (lw6sys_context_t * sys_context, lw6snd_backend_t * backend, char *map_dir, char *music_path, char *music_file) { int ret = 0; char *found_path; LW6SYS_BACKEND_FUNCTION_BEGIN; if (backend->is_music_file) { found_path = lw6sys_find_in_dir_and_path (sys_context, map_dir, music_path, music_file); if (found_path) { ret = backend->is_music_file (sys_context, backend->snd_context, found_path); LW6SYS_FREE (sys_context, found_path); } } else { _warning (sys_context, __FUNCTION__); } LW6SYS_BACKEND_FUNCTION_END; return ret; }
int cmd_help(void *info, t_msg *msg) { int cmd; static const char hasht[CMD_NB][BUF_SIZE] = { " 'help' -> Display help", " 'quit' -> Exit the client", " 'ls' -> List file in server current directory", " 'pwd' -> Print current working directory", " 'cd' <dir> -> Change current directory", " 'get' <file> -> Download file", " 'put'<file> -> Upload file" }; (void)info; if (!strlen(msg->arg)) { printf("Available commands :\n quit help ls\n pwd cd get\n put\n"); printf(" - Type 'help <command>' to open specific help\n"); return (ISUCCESS); } if ((cmd = get_command(msg->arg)) < 0) return (_warning("Unknown command '%s'\n", -1, msg->arg)); printf("%s\n", hasht[cmd]); return (ISUCCESS); }
void warningx2(const char *fmt, ...) { va_list ap; va_start(ap, fmt); _warning(0, fmt, ap); va_end(ap); }
void errorx(int eval, const char *fmt, ...) { va_list ap; va_start(ap, fmt); _warning(0, fmt, ap); va_end(ap); cleanup(0); exit(eval); }
void Opcode8107::_run() { Logger::debug("SCRIPT") << "[8107] [*] void obj_set_light_level(Object* object, int level, int radius)" << std::endl; auto object = _script->dataStack()->popObject(); auto level = _script->dataStack()->popInteger(); auto radius = _script->dataStack()->popInteger(); if (level > 100 || level < 0) { _warning("obj_set_light_level: level should be 0-100"); return; } if (radius > 8 || radius < 0) { _warning("obj_set_light_level: radius should be 0-8"); return; } unsigned int light = 65536 / 100 * level; object->setLightIntensity(light); object->setLightRadius(radius); }
int cmd_cd(void *info, t_msg *msg) { t_client *client; char buf[BUF_SIZE]; client = (t_client*)info; memset(buf, 0, BUF_SIZE); if (!strlen(msg->arg)) return (_warning("Usage : cd <dir>\n", -1)); strcat(buf, "cd "); strcat(buf, msg->arg); if (write(client->sock_fd, buf, strlen(buf)) < 0) return (_warning("Can't write on socket : %m\n", -1)); memset(buf, 0, BUF_SIZE); if (client_read_sock(client->sock_fd, buf, BUF_SIZE) >= 0) write(1, buf, strlen(buf)); else return (_error("[ERROR]\nCan't reach the server : %m\n", -1)); return (ISUCCESS); }
void errorx2(int eval, const char *fmt, ...) { va_list ap; va_start(ap, fmt); _warning(0, fmt, ap); va_end(ap); plugin_cleanup(0); siglongjmp(error_jmp, eval); }
static int receive_file(t_handle *handle, int size, char *name) { char path[PATH_SIZE + BUF_SIZE]; char *buf; int fd; if (!(buf = malloc(sizeof(char) * size))) return (_error("Can't allocate memory : %m\n", -1)); if (read(handle->cli_fd, buf, size) < 0) return (_error("Can't read on client socket : %m\n", -1)); memset(path, 0, PATH_SIZE + BUF_SIZE); strcat(path, handle->path); strcat(path, "/"); strcat(path, name); if ((fd = open(path, O_CREAT | O_RDWR, U_RW)) < 0) return (_warning("Can't create file : %m\n", -1)); if (write(fd, buf, size) < 0) return (_warning("Can't create file : %m\n", -1)); close(fd); free(buf); return (ISUCCESS); }
void sourceFile(Thread& thread, std::string name, Environment* env) { if(thread.state.verbose) std::cout << "Sourcing " << name << std::endl; try { std::ifstream t(name.c_str()); std::stringstream buffer; buffer << t.rdbuf(); std::string code = buffer.str(); Parser parser(thread.state); Value value; FILE* trace = NULL;//fopen((name+"_trace").c_str(), "w"); parser.execute(code.c_str(), code.length(), true, value, trace); //fclose(trace); thread.eval(Compiler::compileTopLevel(thread, value), env); } catch(RiposteError& error) { _warning(thread, "unable to load library " + name + ": " + error.what().c_str()); } catch(RuntimeError& error) { _warning(thread, "unable to load library " + name + ": " + error.what().c_str()); } catch(CompileError& error) { _warning(thread, "unable to load library " + name + ": " + error.what().c_str()); } }
void Opcode812FHandler::_run() { Logger::debug("SCRIPT") << "[812F] [+] void obj_unlock(GameObject* object)" << std::endl; auto object = _vm->dataStack()->popObject(); if (object) { if (auto door = dynamic_cast<Game::GameDoorSceneryObject*>(object)) { door->setLocked(false); } else if (auto container = dynamic_cast<Game::GameContainerItemObject*>(object)) { container->setLocked(false); } else { _warning("obj_unlock: object is not door or container"); } } else { _warning("obj_unlock: object is null"); } }
static int receive_file_info(t_handle *handle, int *size, char *name) { char buf[BUF_SIZE]; char *tok; if (server_read_sock(handle, buf) < 0) return (IWARNING); tok = strtok(buf, " "); memcpy(name, tok, strlen(tok)); tok = strtok(NULL, " "); *size = atoi(tok); if (*size <= 0) return (_warning("Invalid size\n", -1)); return (ISUCCESS); }
int LumpedMassElement :: checkConsistency() // // check internal consistency // { int _result = StructuralElement :: checkConsistency(); int _ndofs = this->computeNumberOfDofs(EID_MomentumBalance); if ( _ndofs != this->components.giveSize() ) { _warning("checkConsistency : component array size mismatch"); _result = 0; } return _result; }
/** * lw6snd_set_music_volume * * @sys_context: global system context * @backend: sound backend to use * @volume: music volume * * Changes music volume. * * Return value: none. */ void lw6snd_set_music_volume (lw6sys_context_t * sys_context, lw6snd_backend_t * backend, float volume) { LW6SYS_BACKEND_FUNCTION_BEGIN; if (backend->set_music_volume) { backend->set_music_volume (sys_context, backend->snd_context, volume); } else { _warning (sys_context, __FUNCTION__); } LW6SYS_BACKEND_FUNCTION_END; }
int cmd_quit(void *info, t_msg *msg) { t_client *client; char buf[BUF_SIZE]; (void)msg; client = (t_client*)info; memset(buf, 0, BUF_SIZE); if (write(client->sock_fd, "quit", 4) < 0) return (_warning("Can't write on socket : %m\n", -1)); if (client_read_sock(client->sock_fd, buf, BUF_SIZE) >= 0) write(1, buf, strlen(buf)); else return (_error("[ERROR]\nCan't reach the server : %m\n", -1)); return (QUIT); }
/** * lw6snd_stop_music * * @sys_context: global system context * @backend: sound backend to use * * Stops the music. * * Return value: none. */ void lw6snd_stop_music (lw6sys_context_t * sys_context, lw6snd_backend_t * backend) { LW6SYS_BACKEND_FUNCTION_BEGIN; if (backend->stop_music) { backend->stop_music (sys_context, backend->snd_context); } else { _warning (sys_context, __FUNCTION__); } LW6SYS_BACKEND_FUNCTION_END; }
/** * lw6snd_init * * @sys_context: global system context * @backend: the graphical backend to use * @fx_volume: sound fx volume * @water_volume: water sounds volume * @music_volume: music volume * * Sets up the sound backend for good, initializing a playback engine * ready to play sounds and set to defaults. * This call can typically fail if there's no device available, if * the user doesn't have enough rights to access the hardware, and so on. * * Return value: 1 on success, 0 if not */ int lw6snd_init (lw6sys_context_t * sys_context, lw6snd_backend_t * backend, float fx_volume, float water_volume, float music_volume) { LW6SYS_BACKEND_FUNCTION_BEGIN; if (backend->init) { backend->snd_context = backend->init (sys_context, backend->argc, backend->argv, fx_volume, water_volume, music_volume); } else { _warning (sys_context, __FUNCTION__); } LW6SYS_BACKEND_FUNCTION_END; return backend->snd_context ? 1 : 0; }
/** * lw6snd_poll * * @sys_context: global system context * @backend: sound backend to use * * Polling function, must be called on a regular basis. * * Return value: none. */ void lw6snd_poll (lw6sys_context_t * sys_context, lw6snd_backend_t * backend) { LW6SYS_BACKEND_FUNCTION_BEGIN; if (backend->poll) { if (backend->snd_context) { backend->poll (sys_context, backend->snd_context); } } else { _warning (sys_context, __FUNCTION__); } LW6SYS_BACKEND_FUNCTION_END; }
/** * lw6snd_repr * * @sys_context: global system context * @backend: the backend to represent * * Returns a readable version of the backend object. * * Return value: a newly allocated pointer. */ char * lw6snd_repr (lw6sys_context_t * sys_context, const lw6snd_backend_t * backend) { char *ret = NULL; LW6SYS_BACKEND_FUNCTION_BEGIN; if (backend->repr) { ret = backend->repr (sys_context, backend->snd_context, backend->id); } else { _warning (sys_context, __FUNCTION__); } LW6SYS_BACKEND_FUNCTION_END; return ret; }
/** * lw6snd_play_fx * * @sys_context: global system context * @backend: sound backend to use * @fx_id: sound fx id * * Plays a sound fx. * * Return value: 1 on success, 0 on error */ int lw6snd_play_fx (lw6sys_context_t * sys_context, lw6snd_backend_t * backend, int fx_id) { int ret = 0; LW6SYS_BACKEND_FUNCTION_BEGIN; if (backend->play_fx) { ret = backend->play_fx (sys_context, backend->snd_context, fx_id); } else { _warning (sys_context, __FUNCTION__); } LW6SYS_BACKEND_FUNCTION_END; return ret; }
static int get_file_info(t_handle *handle, int *size, char *name) { t_stat info; char buf[BUF_SIZE]; memset(buf, 0, BUF_SIZE); if (name[strlen(name) - 1] == '\n') name[strlen(name) - 1] = '\0'; if (stat(name, &info) < 0) return (_warning("Can't get file info : %m\n", -1)); *size = info.st_size; sprintf(buf, "%d", (int)info.st_size); if (write(handle->cli_fd, buf, strlen(buf)) < 0) return (_error("Can't write on client %d: %m\n", -1, handle->cli_num)); memset(buf, 0, BUF_SIZE); if (server_read_sock(handle, buf) < 0) return (IWARNING); if (!strncmp(buf, "OK", 2)) return (ISUCCESS); return (IWARNING); }
/** * lw6snd_play_music_random * * @sys_context: global system context * @backend: sound backend to use * @map_dir: map directory, to search additionnal files * @music_path: config entry containing multiple paths * @music_filter: string filter, must be present * @music_exclude: string filter, must not be present * * Plays a random music file. The filter and exclude mecanisms * are not complete regex filters, only a quick and dirty feature * which should still help in some cases, such as sorting musics * for the menus and for the rest. * * Return value: 1 if OK, 0 if not. */ int lw6snd_play_music_random (lw6sys_context_t * sys_context, lw6snd_backend_t * backend, char *music_path, char *music_filter, char *music_exclude) { int ret = 0; LW6SYS_BACKEND_FUNCTION_BEGIN; if (backend->play_music_random) { lw6sys_log (sys_context, LW6SYS_LOG_DEBUG, _x_ ("picking a random song in \"%s\" using filter \"%s\" and exclude \"%s\""), music_path, music_filter, music_exclude); ret = backend->play_music_random (sys_context, backend->snd_context, music_path, music_filter, music_exclude); } else { _warning (sys_context, __FUNCTION__); } LW6SYS_BACKEND_FUNCTION_END; return ret; }
/** * lw6snd_quit * * @sys_context: global system context * @backend: the backend to quit * * Uninitializes the backend, that is, releases resources, stops playback. * * Return value: none. */ void lw6snd_quit (lw6sys_context_t * sys_context, lw6snd_backend_t * backend) { LW6SYS_BACKEND_FUNCTION_BEGIN; if (backend->quit) { /* * It's important to check that backend is not NULL for * quit can *really* be called several times on the same backend */ if (backend->snd_context) { backend->quit (sys_context, backend->snd_context); backend->snd_context = NULL; } } else { _warning (sys_context, __FUNCTION__); } LW6SYS_BACKEND_FUNCTION_END; }
void QTRSpace :: NodalAveragingRecoveryMI_computeNodalValue(FloatArray &answer, int node, InternalStateType type, TimeStep *tStep) { answer.resize(0); _warning("QTRSpace element: IP values will not be transferred to nodes. Use ZZNodalRecovery instead (parameter stype 1)"); }
int RigidArmNode :: computeMasterContribution() { int i, j, k, sign; IntArray R_uvw(3), uvw(3); FloatArray xyz(3); DofIDItem id; // decode of masterMask uvw.at(1) = this->findDofWithDofId(R_u); uvw.at(2) = this->findDofWithDofId(R_v); uvw.at(3) = this->findDofWithDofId(R_w); for ( i = 1; i <= 3; i++ ) { xyz.at(i) = this->giveCoordinate(i) - masterNode->giveCoordinate(i); } if ( hasLocalCS() ) { // LCS is stored as global-to-local, so LCS*xyz_glob = xyz_loc xyz.rotatedWith(* this->localCoordinateSystem, 'n'); } for ( i = 1; i <= numberOfDofs; i++ ) { id = this->giveDof(i)->giveDofID(); R_uvw.zero(); switch ( masterMask->at(i) ) { case 0: continue; break; case 1: if ( id == D_u ) { if ( uvw.at(2) && masterMask->at( uvw.at(2) ) ) { R_uvw.at(3) = ( ( int ) R_v ); } if ( uvw.at(3) && masterMask->at( uvw.at(3) ) ) { R_uvw.at(2) = -( ( int ) R_w ); } } else if ( id == D_v ) { if ( uvw.at(1) && masterMask->at( uvw.at(1) ) ) { R_uvw.at(3) = -( ( int ) R_u ); } if ( uvw.at(3) && masterMask->at( uvw.at(3) ) ) { R_uvw.at(1) = ( ( int ) R_w ); } } else if ( id == D_w ) { if ( uvw.at(1) && masterMask->at( uvw.at(1) ) ) { R_uvw.at(2) = ( ( int ) R_u ); } if ( uvw.at(2) && masterMask->at( uvw.at(2) ) ) { R_uvw.at(1) = -( ( int ) R_v ); } } break; default: _warning("computeMasterContribution: unknown value in masterMask"); return 0; } k = ++countOfMasterDofs->at(i); masterDofID [ i - 1 ]->at(k) = ( int ) id; masterContribution [ i - 1 ]->at(k) = 1.0; for ( j = 1; j <= 3; j++ ) { if ( R_uvw.at(j) != 0 ) { sign = R_uvw.at(j) < 0 ? -1 : 1; k = ++countOfMasterDofs->at(i); masterDofID [ i - 1 ]->at(k) = sign * R_uvw.at(j); masterContribution [ i - 1 ]->at(k) = sign * xyz.at(j); } } } return 1; }