// 1 accuracy // 2 speed // 3 stamina // 4 stealth // 5 strength // 6 technical void NS_HandleCreateClassMenu( gentity_t *ent, int menuSlot ) { switch ( menuSlot ) { case 1: if ( NS_GotEnoughXPfornextLevel( ent, ent->client->pers.nsPC.accuracy ) && ent->client->pers.nsPC.accuracy < 10 ) { ent->client->pers.nsPC.accuracy++; NS_GiveXP( ent, ent->client->pers.nsPC.accuracy, qtrue ); } else { PrintMsg( ent, "Not enough Experience Points\n" ); } NS_OpenCreateClassMenu( ent ); break; case 2: if ( NS_GotEnoughXPfornextLevel( ent, ent->client->pers.nsPC.speed ) && ent->client->pers.nsPC.speed < 10 ) { ent->client->pers.nsPC.speed++; NS_GiveXP( ent, ent->client->pers.nsPC.speed, qtrue ); } else { PrintMsg( ent, "Not enough Experience Points\n" ); } NS_OpenCreateClassMenu( ent ); break; case 3: if ( NS_GotEnoughXPfornextLevel( ent, ent->client->pers.nsPC.stamina ) && ent->client->pers.nsPC.stamina < 10 ) { ent->client->pers.nsPC.stamina++; NS_GiveXP( ent, ent->client->pers.nsPC.stamina, qtrue ); } else { PrintMsg( ent, "Not enough Experience Points\n" ); } NS_OpenCreateClassMenu( ent ); break; case 4: if ( NS_GotEnoughXPfornextLevel( ent, ent->client->pers.nsPC.stealth ) && ent->client->pers.nsPC.stealth < 10 ) { ent->client->pers.nsPC.stealth++; ent->client->ps.stats[STAT_STEALTH]++ ; NS_GiveXP( ent, ent->client->pers.nsPC.stealth, qtrue ); } else { PrintMsg( ent, "Not enough Experience Points\n" ); } NS_OpenCreateClassMenu( ent ); break; case 5: if ( NS_GotEnoughXPfornextLevel( ent, ent->client->pers.nsPC.strength ) && ent->client->pers.nsPC.strength < 10 ) { ent->client->pers.nsPC.strength++; NS_GiveXP( ent, ent->client->pers.nsPC.strength, qtrue ); } else { PrintMsg( ent, "Not enough Experience Points\n" ); } NS_OpenCreateClassMenu( ent ); break; case 6: if ( NS_GotEnoughXPfornextLevel( ent, ent->client->pers.nsPC.technical ) && ent->client->pers.nsPC.technical < 10 ) { ent->client->pers.nsPC.technical++; NS_GiveXP( ent, ent->client->pers.nsPC.technical, qtrue ); } else { PrintMsg( ent, "Not enough Experience Points\n" ); } NS_OpenCreateClassMenu( ent ); break; case 7: NS_OpenMainMenu( ent ); break; default: break; } }
void NS_HandlePrimaryWeaponMenu( gentity_t *ent, int menuSlot ) { qboolean seals = ( ent->client->sess.sessionTeam == TEAM_RED ); int acc = ent->client->pers.nsPC.accuracy; int str = ent->client->pers.nsPC.strength; // mp5,m4,remington870 // spas-15 str > 6 // psg-1 accuracy > 6 // pdw str > 3 & accuracy > 4 // macmillan accuracy > 8 & str > 4 switch ( menuSlot ) { case 1: if ( seals ) { NS_SetPrimary( ent, WP_MP5 ); } else { NS_SetPrimary( ent, WP_MAC10 ); } NS_OpenMainMenu( ent ); break; case 2: if ( seals ) { NS_SetPrimary( ent, WP_M4 ); } else { NS_SetPrimary( ent, WP_AK47 ); } NS_OpenMainMenu( ent ); break; case 3: NS_SetPrimary( ent, WP_870 ); NS_OpenMainMenu( ent ); break; case 4: if ( str > 6 ) { NS_SetPrimary( ent, WP_SPAS15 ); NS_OpenMainMenu( ent ); } else { PrintMsg( ent,"You're not good enough for this weapon.\n" ); NS_OpenPrimaryWeaponMenu( ent ); } break; case 6: if ( str > 3 && acc > 4 ) { NS_SetPrimary( ent, WP_PDW ); NS_OpenMainMenu( ent ); } else { PrintMsg( ent,"You're not good enough for this weapon.\n" ); NS_OpenPrimaryWeaponMenu( ent ); } break; case 5: if ( acc > 6 ) { NS_SetPrimary( ent, WP_PSG1 ); NS_OpenMainMenu( ent ); } else { PrintMsg( ent,"You're not good enough for this weapon.\n" ); NS_OpenPrimaryWeaponMenu( ent ); } break; case 7: if ( acc > 8 && str > 4 ) { NS_SetPrimary( ent, WP_MACMILLAN ); NS_OpenMainMenu( ent ); } else { PrintMsg( ent,"You're not good enough for this weapon.\n" ); NS_OpenPrimaryWeaponMenu( ent ); } break; case 10: NS_OpenMainMenu( ent ); break; default: NS_OpenPrimaryWeaponMenu( ent ); break; } }
void KICAD_MANAGER_FRAME::OnUnarchiveFiles( wxCommandEvent& event ) { wxFileName fn = GetProjectFileName(); fn.SetExt( ZipFileExtension ); wxFileDialog zipfiledlg( this, _( "Unzip Project" ), fn.GetPath(), fn.GetFullName(), ZipFileWildcard, wxFD_OPEN | wxFD_FILE_MUST_EXIST ); if( zipfiledlg.ShowModal() == wxID_CANCEL ) return; wxString msg = wxString::Format( _("\nOpen '%s'\n" ), GetChars( zipfiledlg.GetPath() ) ); PrintMsg( msg ); wxDirDialog dirDlg( this, _( "Target Directory" ), fn.GetPath(), wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST ); if( dirDlg.ShowModal() == wxID_CANCEL ) return; wxString unzipDir = dirDlg.GetPath() + wxT( "/" ); msg.Printf( _( "Unzipping project in '%s'\n" ), GetChars( unzipDir ) ); PrintMsg( msg ); wxFileSystem zipfilesys; zipfilesys.AddHandler( new wxZipFSHandler ); zipfilesys.ChangePathTo( zipfiledlg.GetPath() + wxT( "#zip:" ), true ); wxFSFile* zipfile = NULL; wxString localfilename = zipfilesys.FindFirst( wxT( "*.*" ) ); while( !localfilename.IsEmpty() ) { zipfile = zipfilesys.OpenFile( localfilename ); if( !zipfile ) { DisplayError( this, wxT( "Zip file read error" ) ); break; } wxFileName uzfn = localfilename.AfterLast( ':' ); uzfn.MakeAbsolute( unzipDir ); wxString unzipfilename = uzfn.GetFullPath(); msg.Printf( _( "Extract file '%s'" ), GetChars( unzipfilename ) ); PrintMsg( msg ); wxInputStream* stream = zipfile->GetStream(); wxFFileOutputStream* ofile = new wxFFileOutputStream( unzipfilename ); if( ofile->Ok() ) { ofile->Write( *stream ); PrintMsg( _( " OK\n" ) ); } else PrintMsg( _( " *ERROR*\n" ) ); delete ofile; delete zipfile; localfilename = zipfilesys.FindNext(); } PrintMsg( wxT( "** end **\n" ) ); }
static int Parse( char *Cmd ) /***************************/ { char opt; char *end; FILE *atfp; char buffer[_MAX_PATH]; char unquoted[_MAX_PATH]; int len; char *p; int wcc_option; list *new_item; /* Cmd will always begin with at least one */ /* non-space character if we get this far */ for( ;; ) { Cmd = SkipSpaces( Cmd ); if( *Cmd == '\0' ) break; opt = *Cmd; if( opt == '-' || opt == Switch_Chars[1] ) { Cmd++; } else if( opt != '@' ) { opt = ' '; } end = Cmd; if( *Cmd == '"' ) { end = FindNextWS( end ); } else { end = FindNextWSOrOpt( end, opt, Switch_Chars ); } len = end - Cmd; if( len != 0 ) { if( opt == ' ' ) { /* if filename, add to list */ strncpy( Word, Cmd, len ); Word[len] = '\0'; end = ScanFName( end, len ); UnquoteFName( unquoted, sizeof( unquoted ), Word ); new_item = MemAlloc( sizeof( list ) ); new_item->next = NULL; new_item->item = MemStrDup( unquoted ); if( FileExtension( Word, ".lib" ) ) { ListAppend( &Libs_List, new_item ); } else if( FileExtension( Word, ".res" ) ) { ListAppend( &Res_List, new_item ); } else { ListAppend( &Files_List, new_item ); } } else { /* otherwise, do option */ --len; strncpy( Word, Cmd + 1, len ); Word[len] = '\0'; wcc_option = 1; /* assume it's a wcc option */ switch( tolower( *Cmd ) ) { case 'b': /* possibly -bcl */ if( strnicmp( Word, "cl=", 3 ) == 0 ) { strcat( CC_Opts, " -bt=" ); strcat( CC_Opts, Word+3 ); Flags.link_for_sys = TRUE; MemFree( SystemName ); SystemName = MemStrDup( Word+3 ); wcc_option = 0; } break; case 'f': /* files option */ p = ScanFName( end, len ); switch( tolower( Word[0] ) ) { case 'd': /* name of linker directive file */ if( Word[1] == '=' || Word[1] == '#' ) { end = p; /* remove quotes from target linker control filename */ UnquoteFName( unquoted, sizeof( unquoted ), Word + 2 ); MakeName( unquoted, ".lnk" ); /* add extension */ MemFree( Link_Name ); Link_Name = MemStrDup( unquoted ); } else { MemFree( Link_Name ); Link_Name = MemStrDup( TEMPFILE ); } wcc_option = 0; break; case 'e': /* name of exe file */ if( Word[1] == '=' || Word[1] == '#' ) { end = p; /* remove quotes from target executable filename */ UnquoteFName( unquoted, sizeof( unquoted ), Word + 2 ); strcpy( Exe_Name, unquoted ); } wcc_option = 0; break; case 'i': /* name of forced include file */ end = p; break; case 'm': /* name of map file */ Flags.map_wanted = TRUE; if( Word[1] == '=' || Word[1] == '#' ) { end = p; /* remove quotes from target map filename */ UnquoteFName( unquoted, sizeof( unquoted ), Word + 2 ); MemFree( Map_Name ); Map_Name = MemStrDup( unquoted ); } wcc_option = 0; break; case 'o': /* name of object file */ end = p; /* parse off argument, so we get right filename in linker command file */ p = &Word[1]; if( Word[1] == '=' || Word[1] == '#' ) ++p; /* remove quotes from object name */ UnquoteFName( unquoted, sizeof( unquoted ), p ); MemFree( Obj_Name ); Obj_Name = MemStrDup( unquoted ); break; #if defined( WCLI86 ) || defined( WCL386 ) case 'p': /* floating-point option */ end = p; if( tolower( Word[1] ) == 'c' ) { Flags.math_8087 = 0; } break; #endif default: end = p; break; } break; case 'k': /* stack size option */ if( Word[0] != '\0' ) { MemFree( StackSize ); StackSize = MemStrDup( Word ); } wcc_option = 0; break; case 'l': /* link target option */ switch( (Word[1] << 8) | tolower( Word[0] ) ) { case 'p': Flags.link_for_dos = 0; Flags.link_for_os2 = TRUE; break; case 'r': Flags.link_for_dos = TRUE; Flags.link_for_os2 = 0; break; default: /* 10-jun-91 */ Flags.link_for_sys = TRUE; p = &Word[0]; if( Word[0] == '=' || Word[0] == '#' ) ++p; MemFree( SystemName ); SystemName = MemStrDup( p ); break; } wcc_option = 0; break; case '@': if( Word[0] != '\0' ) { char const * const env = getenv( Word ); if( env != NULL ) { if( handle_environment_variable( env ) ) { return( 1 ); // Recursive call failed } via_environment = TRUE; Cmd = end; continue; } end = ScanFName( end, len ); /* remove quotes from additional linker options file */ UnquoteFName( unquoted, sizeof( unquoted ), Word ); strcpy( Word, unquoted ); MakeName( Word, ".lnk" ); errno = 0; if( (atfp = fopen( Word, "r" )) == NULL ) { PrintMsg( WclMsgs[UNABLE_TO_OPEN_DIRECTIVE_FILE], Word, strerror( errno ) ); return( 1 ); } while( fgets( buffer, sizeof( buffer ), atfp ) != NULL ) { if( strnicmp( buffer, "file ", 5 ) == 0 ) { /* look for names separated by ','s */ p = strchr( buffer, '\n' ); if( p != NULL ) *p = '\0'; AddName( &buffer[5], Fp ); Flags.do_link = TRUE; } else { fputs( buffer, Fp ); } } fclose( atfp ); } wcc_option = 0; break; /* compiler options that affect the linker */ #ifdef WCL386 case '3': case '4': case '5': /* 22-sep-92 */ Conventions = tolower( Word[0] ); break; #endif case 'd': if( DebugFlag == 0 ) { /* not set by -h yet */ if( strcmp( Word, "1" ) == 0 ) { DebugFlag = 1; } else if( strcmp( Word, "1+" ) == 0 ) { /* 02-mar-91 */ DebugFlag = 2; } else if( strcmp( Word, "2" ) == 0 ) { DebugFlag = 2; } else if( strcmp( Word, "2i" ) == 0 ) { DebugFlag = 2; } else if( strcmp( Word, "2s" ) == 0 ) { DebugFlag = 2; } else if( strcmp( Word, "3" ) == 0 ) { DebugFlag = 2; } else if( strcmp( Word, "3i" ) == 0 ) { DebugFlag = 2; } else if( strcmp( Word, "3s" ) == 0 ) { DebugFlag = 2; } } break; case 'h': if( strcmp( Word, "w" ) == 0 ) { DebugFlag = 3; } else if( strcmp( Word, "c" ) == 0 ) { /* 02-mar-91 */ Flags.do_cvpack = 1; DebugFlag = 4; } else if( strcmp( Word, "d" ) == 0 ) { DebugFlag = 5; } break; case 'i': /* include file path */ end = ScanFName( end, len ); break; case 'c': /* compile only */ if( stricmp( Word, "c" ) == 0 ) { Flags.force_c = TRUE; } else if( stricmp( Word, "c++" ) == 0 ) { Flags.force_c_plus = TRUE; } else { Flags.no_link = TRUE; } /* fall through */ case 'y': wcc_option = 0; break; #if defined( WCLI86 ) || defined( WCL386 ) case 'm': /* memory model */ if( Cmd[1] == 't' || Cmd[1] == 'T' ) { /* tiny model*/ Word[0] = 's'; /* change to small */ Flags.tiny_model = TRUE; } break; #endif case 'p': Flags.no_link = TRUE; break; /* this is a preprocessor option */ case 'q': Flags.be_quiet = TRUE; break; case 'z': /* 12-jan-89 */ switch( tolower( Cmd[1] ) ) { case 's': Flags.no_link = TRUE; break; case 'q': Flags.be_quiet = TRUE; break; #ifdef WCLI86 case 'w': Flags.windows = TRUE; #endif } break; case '"': /* 17-dec-91 */ /* As parameter passing to linker is a special case, we need to pass * whole command instead of first character removed. This allows us * to parse also string literals in AddDirective. */ wcc_option = 0; strncpy( Word, Cmd, ++len ); Word[len] = '\0'; AddDirective( len ); break; } /* don't add linker-specific options */ /* to compiler command line: */ if( wcc_option ) { len = strlen( CC_Opts ); CC_Opts[len++] = ' '; CC_Opts[len++] = opt; CC_Opts[len++] = *Cmd; /* keep original case */ CC_Opts[len] = '\0'; strcat( CC_Opts, Word ); } } Cmd = end; } } return( 0 ); }
/* ================ Team_FragBonuses Calculate the bonuses for flag defense, flag carrier defense, etc. Note that bonuses are not cumulative. You get one, they are in importance order. ================ */ void Team_FragBonuses(gentity_t *targ, gentity_t *inflictor, gentity_t *attacker) { int i; gentity_t *ent; int flag_pw, enemy_flag_pw; int otherteam; int tokens; gentity_t *flag, *carrier = NULL; char *c; vec3_t v1, v2; int team; // no bonus for fragging yourself or team mates if (!targ->client || !attacker->client || targ == attacker || OnSameTeam(targ, attacker)) return; team = targ->client->sess.sessionTeam; otherteam = OtherTeam(targ->client->sess.sessionTeam); if (otherteam < 0) return; // whoever died isn't on a team // same team, if the flag at base, check to he has the enemy flag if (team == TEAM_RED) { flag_pw = PW_REDFLAG; enemy_flag_pw = PW_BLUEFLAG; } else { flag_pw = PW_BLUEFLAG; enemy_flag_pw = PW_REDFLAG; } #ifdef MISSIONPACK if (g_gametype.integer == GT_1FCTF) { enemy_flag_pw = PW_NEUTRALFLAG; } #endif // did the attacker frag the flag carrier? tokens = 0; #ifdef MISSIONPACK if( g_gametype.integer == GT_HARVESTER ) { tokens = targ->client->ps.generic1; } #endif if (targ->client->ps.powerups[enemy_flag_pw]) { attacker->client->pers.teamState.lastfraggedcarrier = level.time; AddScore(attacker, targ->r.currentOrigin, CTF_FRAG_CARRIER_BONUS); attacker->client->pers.teamState.fragcarrier++; PrintMsg(NULL, "%s" S_COLOR_WHITE " fragged %s's flag carrier!\n", attacker->client->pers.netname, TeamName(team)); // the target had the flag, clear the hurt carrier // field on the other team for (i = 0; i < g_maxclients.integer; i++) { ent = g_entities + i; if (ent->inuse && ent->client->sess.sessionTeam == otherteam) ent->client->pers.teamState.lasthurtcarrier = 0; } return; } // did the attacker frag a head carrier? other->client->ps.generic1 if (tokens) { attacker->client->pers.teamState.lastfraggedcarrier = level.time; AddScore(attacker, targ->r.currentOrigin, CTF_FRAG_CARRIER_BONUS * tokens * tokens); attacker->client->pers.teamState.fragcarrier++; PrintMsg(NULL, "%s" S_COLOR_WHITE " fragged %s's skull carrier!\n", attacker->client->pers.netname, TeamName(team)); // the target had the flag, clear the hurt carrier // field on the other team for (i = 0; i < g_maxclients.integer; i++) { ent = g_entities + i; if (ent->inuse && ent->client->sess.sessionTeam == otherteam) ent->client->pers.teamState.lasthurtcarrier = 0; } return; } if (targ->client->pers.teamState.lasthurtcarrier && level.time - targ->client->pers.teamState.lasthurtcarrier < CTF_CARRIER_DANGER_PROTECT_TIMEOUT && !attacker->client->ps.powerups[flag_pw]) { // attacker is on the same team as the flag carrier and // fragged a guy who hurt our flag carrier AddScore(attacker, targ->r.currentOrigin, CTF_CARRIER_DANGER_PROTECT_BONUS); attacker->client->pers.teamState.carrierdefense++; targ->client->pers.teamState.lasthurtcarrier = 0; attacker->client->ps.persistant[PERS_DEFEND_COUNT]++; // add the sprite over the player's head attacker->client->ps.eFlags &= ~(EF_AWARD_IMPRESSIVE | EF_AWARD_EXCELLENT | EF_AWARD_GAUNTLET | EF_AWARD_ASSIST | EF_AWARD_DEFEND | EF_AWARD_CAP ); attacker->client->ps.eFlags |= EF_AWARD_DEFEND; attacker->client->rewardTime = level.time + REWARD_SPRITE_TIME; return; } if (targ->client->pers.teamState.lasthurtcarrier && level.time - targ->client->pers.teamState.lasthurtcarrier < CTF_CARRIER_DANGER_PROTECT_TIMEOUT) { // attacker is on the same team as the skull carrier and AddScore(attacker, targ->r.currentOrigin, CTF_CARRIER_DANGER_PROTECT_BONUS); attacker->client->pers.teamState.carrierdefense++; targ->client->pers.teamState.lasthurtcarrier = 0; attacker->client->ps.persistant[PERS_DEFEND_COUNT]++; // add the sprite over the player's head attacker->client->ps.eFlags &= ~(EF_AWARD_IMPRESSIVE | EF_AWARD_EXCELLENT | EF_AWARD_GAUNTLET | EF_AWARD_ASSIST | EF_AWARD_DEFEND | EF_AWARD_CAP ); attacker->client->ps.eFlags |= EF_AWARD_DEFEND; attacker->client->rewardTime = level.time + REWARD_SPRITE_TIME; return; } // flag and flag carrier area defense bonuses // we have to find the flag and carrier entities #ifdef MISSIONPACK if( g_gametype.integer == GT_OBELISK ) { // find the team obelisk switch (attacker->client->sess.sessionTeam) { case TEAM_RED: c = "team_redobelisk"; break; case TEAM_BLUE: c = "team_blueobelisk"; break; default: return; } } else if (g_gametype.integer == GT_HARVESTER ) { // find the center obelisk c = "team_neutralobelisk"; } else { #endif // find the flag switch (attacker->client->sess.sessionTeam) { case TEAM_RED: c = "team_CTF_redflag"; break; case TEAM_BLUE: c = "team_CTF_blueflag"; break; default: return; } // find attacker's team's flag carrier for (i = 0; i < g_maxclients.integer; i++) { carrier = g_entities + i; if (carrier->inuse && carrier->client->ps.powerups[flag_pw]) break; carrier = NULL; } #ifdef MISSIONPACK } #endif flag = NULL; while ((flag = G_Find (flag, FOFS(classname), c)) != NULL) { if (!(flag->flags & FL_DROPPED_ITEM)) break; } if (!flag) return; // can't find attacker's flag // ok we have the attackers flag and a pointer to the carrier // check to see if we are defending the base's flag VectorSubtract(targ->r.currentOrigin, flag->r.currentOrigin, v1); VectorSubtract(attacker->r.currentOrigin, flag->r.currentOrigin, v2); if ( ( ( VectorLength(v1) < CTF_TARGET_PROTECT_RADIUS && trap_InPVS(flag->r.currentOrigin, targ->r.currentOrigin ) ) || ( VectorLength(v2) < CTF_TARGET_PROTECT_RADIUS && trap_InPVS(flag->r.currentOrigin, attacker->r.currentOrigin ) ) ) && attacker->client->sess.sessionTeam != targ->client->sess.sessionTeam) { // we defended the base flag AddScore(attacker, targ->r.currentOrigin, CTF_FLAG_DEFENSE_BONUS); attacker->client->pers.teamState.basedefense++; attacker->client->ps.persistant[PERS_DEFEND_COUNT]++; // add the sprite over the player's head attacker->client->ps.eFlags &= ~(EF_AWARD_IMPRESSIVE | EF_AWARD_EXCELLENT | EF_AWARD_GAUNTLET | EF_AWARD_ASSIST | EF_AWARD_DEFEND | EF_AWARD_CAP ); attacker->client->ps.eFlags |= EF_AWARD_DEFEND; attacker->client->rewardTime = level.time + REWARD_SPRITE_TIME; return; } if (carrier && carrier != attacker) { VectorSubtract(targ->r.currentOrigin, carrier->r.currentOrigin, v1); VectorSubtract(attacker->r.currentOrigin, carrier->r.currentOrigin, v1); if ( ( ( VectorLength(v1) < CTF_ATTACKER_PROTECT_RADIUS && trap_InPVS(carrier->r.currentOrigin, targ->r.currentOrigin ) ) || ( VectorLength(v2) < CTF_ATTACKER_PROTECT_RADIUS && trap_InPVS(carrier->r.currentOrigin, attacker->r.currentOrigin ) ) ) && attacker->client->sess.sessionTeam != targ->client->sess.sessionTeam) { AddScore(attacker, targ->r.currentOrigin, CTF_CARRIER_PROTECT_BONUS); attacker->client->pers.teamState.carrierdefense++; attacker->client->ps.persistant[PERS_DEFEND_COUNT]++; // add the sprite over the player's head attacker->client->ps.eFlags &= ~(EF_AWARD_IMPRESSIVE | EF_AWARD_EXCELLENT | EF_AWARD_GAUNTLET | EF_AWARD_ASSIST | EF_AWARD_DEFEND | EF_AWARD_CAP ); attacker->client->ps.eFlags |= EF_AWARD_DEFEND; attacker->client->rewardTime = level.time + REWARD_SPRITE_TIME; return; } } }
WinEDA_MainFrame::WinEDA_MainFrame(WinEDA_App * eda_app, wxWindow *parent, const wxString & title, const wxPoint& pos, const wxSize& size): WinEDA_BasicFrame(parent, KICAD_MAIN_FRAME, eda_app, title, pos, size ) { wxString msg; wxSize clientsize; m_FrameName = wxT("KicadFrame"); m_VToolBar = NULL; m_LeftWin = NULL; m_BottomWin = NULL; m_CommandWin = NULL; m_LeftWin_Width = 200; m_CommandWin_Height = 82; GetSettings(); if( m_Parent->m_EDA_Config ) { m_Parent->m_EDA_Config->Read(wxT("LeftWinWidth"), &m_LeftWin_Width); m_Parent->m_EDA_Config->Read(wxT("CommandWinWidth"), &m_CommandWin_Height); } SetSize(m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y); // ajuste la ligne de status int dims[3] = { -1, -1, 100}; CreateStatusBar(3); SetStatusWidths(3,dims); // Give an icon SetIcon(wxICON(kicad_icon)); clientsize = GetClientSize(); // Left window: is the box which display tree project m_LeftWin = new WinEDA_PrjFrame(this, wxDefaultPosition, wxDefaultSize); m_LeftWin->SetDefaultSize(wxSize(m_LeftWin_Width, clientsize.y)); m_LeftWin->SetOrientation(wxLAYOUT_VERTICAL); m_LeftWin->SetAlignment(wxLAYOUT_LEFT); m_LeftWin->SetSashVisible(wxSASH_RIGHT, TRUE); m_LeftWin->SetExtraBorderSize(2); // Bottom Window: box to display messages m_BottomWin = new wxSashLayoutWindow(this, ID_BOTTOM_FRAME, wxDefaultPosition, wxDefaultSize, wxNO_BORDER|wxSW_3D); m_BottomWin->SetDefaultSize(wxSize(clientsize.x, 150)); m_BottomWin->SetOrientation(wxLAYOUT_HORIZONTAL); m_BottomWin->SetAlignment(wxLAYOUT_BOTTOM); m_BottomWin->SetSashVisible(wxSASH_TOP, TRUE); m_BottomWin->SetSashVisible(wxSASH_LEFT, TRUE); m_BottomWin->SetExtraBorderSize(2); m_DialogWin = new wxTextCtrl(m_BottomWin, ID_MAIN_DIALOG, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE| wxNO_BORDER| wxTE_READONLY); m_DialogWin->SetFont(* g_StdFont); // m_CommandWin is the box with buttons which launch eechema, pcbnew ... m_CommandWin = new WinEDA_CommandFrame(this, ID_MAIN_COMMAND, wxPoint(m_LeftWin_Width, 0), wxSize(clientsize.x, m_CommandWin_Height), wxNO_BORDER|wxSW_3D); m_CommandWin->SetDefaultSize(wxSize(clientsize.x, 100)); m_CommandWin->SetOrientation(wxLAYOUT_HORIZONTAL); m_CommandWin->SetAlignment(wxLAYOUT_TOP); m_CommandWin->SetSashVisible(wxSASH_BOTTOM, TRUE); m_CommandWin->SetSashVisible(wxSASH_LEFT, TRUE); m_CommandWin->SetExtraBorderSize(2); m_CommandWin->SetFont(* g_StdFont); CreateCommandToolbar(); wxString line; msg = wxGetCwd(); line.Printf( _("Ready\nWorking dir: %s\n"), msg.GetData()); PrintMsg(line); }
/** * a minor helper function: * Prints the Current Project full name on the text panel. */ void KICAD_MANAGER_FRAME::PrintPrjInfo() { wxString msg = wxString::Format( _( "Project name:\n%s\n" ), GetChars( GetProjectFileName() ) ); PrintMsg( msg ); }
int CMsgBox::ReadMsgFile() { int cntCurMsg; int cntReadMsg; long lFileSize = 0; char *buf; MsgPack msg; if(strReadFileName.empty()) return -1; FILE* fp = fopen(strReadFileName.c_str(), "rb"); if( fp ) { fseek(fp, 0, SEEK_END); lFileSize = ftell(fp); if(lFileSize <= MSG_PACKET_SIZE) { fclose(fp); return 0; } else if(lFileSize % MSG_PACKET_SIZE != 0) { printf(">> %s read file size error\n", __func__); fclose(fp); return -2; } buf = new char[lFileSize]; fseek(fp, 0, SEEK_SET); fread(buf, lFileSize, 1, fp); fclose(fp); msg = ((MsgPack *)buf)[0]; cntCurMsg = msg.hdr.msg_no; cntReadMsg = lFileSize/MSG_PACKET_SIZE - 1; if(cntCurMsg != cntReadMsg) { printf(">> %s read file cnt error(cur:%d, read:%d)\n", __func__, cntCurMsg, cntReadMsg); delete []buf; return 0; } InitMsgFile(strReadFileName); for(int i=1; i<=cntCurMsg; i++) { msg = ((MsgPack *)buf)[i]; qReadMsg.push(msg); PrintMsg(msg); } delete []buf; } else return -1; return cntCurMsg; }
/** * Emit a log message. This function is the variable argument list equivalent * to vlc_Log(). */ void vlc_vaLog (vlc_object_t *obj, int type, const char *module, const char *format, va_list args) { if (obj != NULL && obj->i_flags & OBJECT_FLAGS_QUIET) return; /* C locale to get error messages in English in the logs */ locale_t c = newlocale (LC_MESSAGES_MASK, "C", (locale_t)0); locale_t locale = uselocale (c); #ifndef __GLIBC__ /* Expand %m to strerror(errno) - only once */ char buf[strlen(format) + 2001], *ptr; strcpy (buf, format); ptr = (char*)buf; format = (const char*) buf; for( ;; ) { ptr = strchr( ptr, '%' ); if( ptr == NULL ) break; if( ptr[1] == 'm' ) { char errbuf[2001]; size_t errlen; #ifndef WIN32 strerror_r( errno, errbuf, 1001 ); #else int sockerr = WSAGetLastError( ); if( sockerr ) { strncpy( errbuf, net_strerror( sockerr ), 1001 ); WSASetLastError( sockerr ); } if ((sockerr == 0) || (strcmp ("Unknown network stack error", errbuf) == 0)) strncpy( errbuf, strerror( errno ), 1001 ); #endif errbuf[1000] = 0; /* Escape '%' from the error string */ for( char *percent = strchr( errbuf, '%' ); percent != NULL; percent = strchr( percent + 2, '%' ) ) { memmove( percent + 1, percent, strlen( percent ) + 1 ); } errlen = strlen( errbuf ); memmove( ptr + errlen, ptr + 2, strlen( ptr + 2 ) + 1 ); memcpy( ptr, errbuf, errlen ); break; /* Only once, so we don't overflow */ } /* Looks for conversion specifier... */ do ptr++; while( *ptr && ( strchr( "diouxXeEfFgGaAcspn%", *ptr ) == NULL ) ); if( *ptr ) ptr++; /* ...and skip it */ } #endif /* Fill message information fields */ msg_item_t msg; msg.i_object_id = (uintptr_t)obj; msg.psz_object_type = (obj != NULL) ? obj->psz_object_type : "generic"; msg.psz_module = module; msg.psz_header = NULL; for (vlc_object_t *o = obj; o != NULL; o = o->p_parent) if (o->psz_header != NULL) { msg.psz_header = o->psz_header; break; } /* Pass message to subscribers */ libvlc_priv_t *priv = libvlc_priv (obj->p_libvlc); va_list ap; va_copy (ap, args); if (priv->b_color) PrintColorMsg (&priv->i_verbose, type, &msg, format, ap); else PrintMsg (&priv->i_verbose, type, &msg, format, ap); va_end (ap); vlc_rwlock_rdlock (&msg_lock); for (msg_subscription_t *sub = msg_head; sub != NULL; sub = sub->next) { va_copy (ap, args); sub->func (sub->opaque, type, &msg, format, ap); va_end (ap); } vlc_rwlock_unlock (&msg_lock); uselocale (locale); freelocale (c); }
/** * Add a message to a queue * * This function provides basic functionnalities to other msg_* functions. * It adds a message to a queue (after having printed all stored messages if it * is full). If the message can't be converted to string in memory, it issues * a warning. */ void msg_GenericVa (vlc_object_t *p_this, int i_type, const char *psz_module, const char *psz_format, va_list _args) { char * psz_str = NULL; /* formatted message string */ va_list args; assert (p_this); if( p_this->i_flags & OBJECT_FLAGS_QUIET || (p_this->i_flags & OBJECT_FLAGS_NODBG && i_type == VLC_MSG_DBG) ) return; msg_bank_t *bank = libvlc_bank (p_this->p_libvlc); locale_t locale = uselocale (bank->locale); #ifndef __GLIBC__ /* Expand %m to strerror(errno) - only once */ char buf[strlen( psz_format ) + 2001], *ptr; strcpy( buf, psz_format ); ptr = (char*)buf; psz_format = (const char*) buf; for( ;; ) { ptr = strchr( ptr, '%' ); if( ptr == NULL ) break; if( ptr[1] == 'm' ) { char errbuf[2001]; size_t errlen; #ifndef WIN32 strerror_r( errno, errbuf, 1001 ); #else int sockerr = WSAGetLastError( ); if( sockerr ) { strncpy( errbuf, net_strerror( sockerr ), 1001 ); WSASetLastError( sockerr ); } if ((sockerr == 0) || (strcmp ("Unknown network stack error", errbuf) == 0)) strncpy( errbuf, strerror( errno ), 1001 ); #endif errbuf[1000] = 0; /* Escape '%' from the error string */ for( char *percent = strchr( errbuf, '%' ); percent != NULL; percent = strchr( percent + 2, '%' ) ) { memmove( percent + 1, percent, strlen( percent ) + 1 ); } errlen = strlen( errbuf ); memmove( ptr + errlen, ptr + 2, strlen( ptr + 2 ) + 1 ); memcpy( ptr, errbuf, errlen ); break; /* Only once, so we don't overflow */ } /* Looks for conversion specifier... */ do ptr++; while( *ptr && ( strchr( "diouxXeEfFgGaAcspn%", *ptr ) == NULL ) ); if( *ptr ) ptr++; /* ...and skip it */ } #endif /* Convert message to string */ vlc_va_copy( args, _args ); if( vasprintf( &psz_str, psz_format, args ) == -1 ) psz_str = NULL; va_end( args ); if( psz_str == NULL ) { int canc = vlc_savecancel (); /* Do not print half of a message... */ #ifdef __GLIBC__ fprintf( stderr, "main warning: can't store message (%m): " ); #else char psz_err[1001]; #ifndef WIN32 /* we're not using GLIBC, so we are sure that the error description * will be stored in the buffer we provide to strerror_r() */ strerror_r( errno, psz_err, 1001 ); #else strncpy( psz_err, strerror( errno ), 1001 ); #endif psz_err[1000] = '\0'; fprintf( stderr, "main warning: can't store message (%s): ", psz_err ); #endif vlc_va_copy( args, _args ); /* We should use utf8_vfprintf - but it calls malloc()... */ vfprintf( stderr, psz_format, args ); va_end( args ); fputs( "\n", stderr ); vlc_restorecancel (canc); uselocale (locale); return; } uselocale (locale); /* Fill message information fields */ msg_item_t msg; msg.i_type = i_type; msg.i_object_id = (uintptr_t)p_this; msg.psz_object_type = p_this->psz_object_type; msg.psz_module = psz_module; msg.psz_msg = psz_str; msg.psz_header = NULL; for (vlc_object_t *o = p_this; o != NULL; o = o->p_parent) if (o->psz_header != NULL) { msg.psz_header = o->psz_header; break; } PrintMsg( p_this, &msg ); vlc_rwlock_rdlock (&bank->lock); for (int i = 0; i < bank->i_sub; i++) { msg_subscription_t *sub = bank->pp_sub[i]; libvlc_priv_t *priv = libvlc_priv( sub->instance ); msg_bank_t *bank = priv->msg_bank; void *val = vlc_dictionary_value_for_key( &bank->enabled_objects, msg.psz_module ); if( val == kObjectPrintingDisabled ) continue; if( val != kObjectPrintingEnabled ) /*if not allowed */ { val = vlc_dictionary_value_for_key( &bank->enabled_objects, msg.psz_object_type ); if( val == kObjectPrintingDisabled ) continue; if( val == kObjectPrintingEnabled ); /* Allowed */ else if( !bank->all_objects_enabled ) continue; } switch( msg.i_type ) { case VLC_MSG_INFO: case VLC_MSG_ERR: if( sub->verbosity < 0 ) continue; break; case VLC_MSG_WARN: if( sub->verbosity < 1 ) continue; break; case VLC_MSG_DBG: if( sub->verbosity < 2 ) continue; break; } sub->func (sub->opaque, &msg); } vlc_rwlock_unlock (&bank->lock); free (msg.psz_msg); }
/** * Add a message to a queue * * This function provides basic functionnalities to other msg_* functions. * It adds a message to a queue (after having printed all stored messages if it * is full). If the message can't be converted to string in memory, it issues * a warning. */ static void QueueMsg( vlc_object_t *p_this, int i_type, const char *psz_module, const char *psz_format, va_list _args ) { assert (p_this); libvlc_priv_t *priv = libvlc_priv (p_this->p_libvlc); int i_header_size; /* Size of the additionnal header */ vlc_object_t *p_obj; char * psz_str = NULL; /* formatted message string */ char * psz_header = NULL; va_list args; msg_item_t * p_item = NULL; /* pointer to message */ msg_item_t item; /* message in case of a full queue */ msg_queue_t *p_queue; #if !defined(HAVE_VASPRINTF) || defined(__APPLE__) || defined(SYS_BEOS) int i_size = strlen(psz_format) + INTF_MAX_MSG_SIZE; #endif if( p_this->i_flags & OBJECT_FLAGS_QUIET || (p_this->i_flags & OBJECT_FLAGS_NODBG && i_type == VLC_MSG_DBG) ) return; #ifndef __GLIBC__ /* Expand %m to strerror(errno) - only once */ char buf[strlen( psz_format ) + 2001], *ptr; strcpy( buf, psz_format ); ptr = (char*)buf; psz_format = (const char*) buf; for( ;; ) { ptr = strchr( ptr, '%' ); if( ptr == NULL ) break; if( ptr[1] == 'm' ) { char errbuf[2001]; size_t errlen; #ifndef WIN32 strerror_r( errno, errbuf, 1001 ); #else int sockerr = WSAGetLastError( ); if( sockerr ) { strncpy( errbuf, net_strerror( sockerr ), 1001 ); WSASetLastError( sockerr ); } if ((sockerr == 0) || (strcmp ("Unknown network stack error", errbuf) == 0)) strncpy( errbuf, strerror( errno ), 1001 ); #endif errbuf[1000] = 0; /* Escape '%' from the error string */ for( char *percent = strchr( errbuf, '%' ); percent != NULL; percent = strchr( percent + 2, '%' ) ) { memmove( percent + 1, percent, strlen( percent ) + 1 ); } errlen = strlen( errbuf ); memmove( ptr + errlen, ptr + 2, strlen( ptr + 2 ) + 1 ); memcpy( ptr, errbuf, errlen ); break; /* Only once, so we don't overflow */ } /* Looks for conversion specifier... */ do ptr++; while( *ptr && ( strchr( "diouxXeEfFgGaAcspn%", *ptr ) == NULL ) ); if( *ptr ) ptr++; /* ...and skip it */ } #endif /* Convert message to string */ #if defined(HAVE_VASPRINTF) && !defined(__APPLE__) && !defined( SYS_BEOS ) vlc_va_copy( args, _args ); if( vasprintf( &psz_str, psz_format, args ) == -1 ) psz_str = NULL; va_end( args ); #else psz_str = (char*) malloc( i_size ); #endif if( psz_str == NULL ) { #ifdef __GLIBC__ fprintf( stderr, "main warning: can't store message (%m): " ); #else char psz_err[1001]; #ifndef WIN32 /* we're not using GLIBC, so we are sure that the error description * will be stored in the buffer we provide to strerror_r() */ strerror_r( errno, psz_err, 1001 ); #else strncpy( psz_err, strerror( errno ), 1001 ); #endif psz_err[1000] = '\0'; fprintf( stderr, "main warning: can't store message (%s): ", psz_err ); #endif vlc_va_copy( args, _args ); /* We should use utf8_vfprintf - but it calls malloc()... */ vfprintf( stderr, psz_format, args ); va_end( args ); fputs( "\n", stderr ); return; } i_header_size = 0; p_obj = p_this; while( p_obj != NULL ) { char *psz_old = NULL; if( p_obj->psz_header ) { i_header_size += strlen( p_obj->psz_header ) + 4; if( psz_header ) { psz_old = strdup( psz_header ); psz_header = (char*)realloc( psz_header, i_header_size ); snprintf( psz_header, i_header_size , "[%s] %s", p_obj->psz_header, psz_old ); } else { psz_header = (char *)malloc( i_header_size ); snprintf( psz_header, i_header_size, "[%s]", p_obj->psz_header ); } } free( psz_old ); p_obj = p_obj->p_parent; } #if !defined(HAVE_VASPRINTF) || defined(__APPLE__) || defined(SYS_BEOS) vlc_va_copy( args, _args ); vsnprintf( psz_str, i_size, psz_format, args ); va_end( args ); psz_str[ i_size - 1 ] = 0; /* Just in case */ #endif LOCK_BANK; p_queue = &QUEUE; vlc_mutex_lock( &p_queue->lock ); /* Check there is room in the queue for our message */ if( p_queue->b_overflow ) { FlushMsg( p_queue ); if( ((p_queue->i_stop - p_queue->i_start + 1) % VLC_MSG_QSIZE) == 0 ) { /* Still in overflow mode, print from a dummy item */ p_item = &item; } else { /* Pheeew, at last, there is room in the queue! */ p_queue->b_overflow = false; } } else if( ((p_queue->i_stop - p_queue->i_start + 2) % VLC_MSG_QSIZE) == 0 ) { FlushMsg( p_queue ); if( ((p_queue->i_stop - p_queue->i_start + 2) % VLC_MSG_QSIZE) == 0 ) { p_queue->b_overflow = true; /* Put the overflow message in the queue */ p_item = p_queue->msg + p_queue->i_stop; p_queue->i_stop = (p_queue->i_stop + 1) % VLC_MSG_QSIZE; p_item->i_type = VLC_MSG_WARN; p_item->i_object_id = p_this->i_object_id; p_item->psz_object_type = p_this->psz_object_type; p_item->psz_module = strdup( "message" ); p_item->psz_msg = strdup( "message queue overflowed" ); p_item->psz_header = NULL; PrintMsg( p_this, p_item ); /* We print from a dummy item */ p_item = &item; } } if( !p_queue->b_overflow ) { /* Put the message in the queue */ p_item = p_queue->msg + p_queue->i_stop; p_queue->i_stop = (p_queue->i_stop + 1) % VLC_MSG_QSIZE; } /* Fill message information fields */ p_item->i_type = i_type; p_item->i_object_id = p_this->i_object_id; p_item->psz_object_type = p_this->psz_object_type; p_item->psz_module = strdup( psz_module ); p_item->psz_msg = psz_str; p_item->psz_header = psz_header; PrintMsg( p_this, p_item ); if( p_queue->b_overflow ) { free( p_item->psz_module ); free( p_item->psz_msg ); free( p_item->psz_header ); } vlc_mutex_unlock ( &p_queue->lock ); UNLOCK_BANK; }
void Display(FunctionQueue *FQ,PathList *PL) { while (!FunctionEmpty(FQ)) { FuncItem *F; F = FunctionFirst(FQ); switch (F->command) { // Kill command case 0: Kill(F->unit,F->flag,PL); break; // Spawn command case 1: Spawn(F->unit,PL); break; // DrawMap command case 2: DrawMap(F->towerList,PL); break; // DrawMenu command case 3: DrawMenu(); break; // DrawAvailableUnits command case 4: DrawAvailableUnits(F->level,F->unitList); break; // RedrawQueue command case 5: RedrawQueue(F->unitList); break; // RedrawResources command case 6: RedrawResources(F->level); break; // RedrawHP command case 7: RedrawHP(F->level); break; // ClearMap command case 8: ClearMap(); break; // ClearPrompts command case 9: ClearPrompts(); break; // ClearMsg command case 10: ClearMsg(); break; // PrintMsg command case 11: PrintMsg(F->flag); break; // StageLose command case 12: StageLose(); break; // StageWin command case 13: StageWin(); break; default: break; } FunctionDequeue(FQ); } }
void main( int argc, char *argv[] ) { //====================================== int rc; char *wfl_env; char *p; char *q; char *cmd; argc = argc; __InitResource(); __ErrorInit( argv[0] ); CmpOpts[0] = '\0'; SwitchChars[0] = '-'; SwitchChars[1] = _dos_switch_char(); SwitchChars[2] = '\0'; Word = MemAlloc( MAX_CMD ); cmd = MemAlloc( 2*MAX_CMD ); // for "WFL" environment variable and command line // add "WFL" environment variable to "cmd" unless "/y" is specified // in "cmd" or the "WFL" environment string wfl_env = getenv( WFLENV ); if( wfl_env != NULL ) { strcpy( cmd, wfl_env ); strcat( cmd, " " ); p = cmd + strlen( cmd ); getcmd( p ); for( q = cmd; (q = strpbrk( q, SwitchChars )) != NULL; ) { if( tolower( *(++q) ) == 'y' ) { getcmd( cmd ); p = cmd; break; } } } else { getcmd( cmd ); p = cmd; } p = SkipSpaces( p ); if( ( *p == '\0' ) || ( strncmp( p, "? ", 2 ) == NULL ) ) { Usage(); rc = 1; } else { Fp = fopen( TEMPFILE, "w" ); if( Fp == NULL ) { PrintMsg( CL_ERROR_OPENING_TMP_FILE ); rc = 1; } else { ObjName = NULL; rc = Parse( cmd ); if( rc == 0 ) { if( !Flags.quiet ) { PrtBanner(); } rc = CompLink(); } if( rc == 1 ) fclose( Fp ); if( LinkName != NULL ) { if( stricmp( LinkName, TEMPFILE ) != 0 ) { remove( LinkName ); rename( TEMPFILE, LinkName ); } } else { remove( TEMPFILE ); } } } free( Word ); free( cmd ); wfl_exit( rc == 0 ? 0 : 1 ); }
bool SCH_EDIT_FRAME::LoadCacheLibrary( const wxString& aFilename ) { wxString msg; bool LibCacheExist = false; wxFileName fn = aFilename; /* Loading the project library cache * until apr 2009 the lib is named <root_name>.cache.lib * and after (due to code change): <root_name>-cache.lib * so if the <name>-cache.lib is not found, the old way will be tried */ bool use_oldcachename = false; wxString cachename = fn.GetName() + wxT( "-cache" ); fn.SetName( cachename ); fn.SetExt( SchematicLibraryFileExtension ); if( ! fn.FileExists() ) { fn = aFilename; fn.SetExt( wxT( "cache.lib" ) ); use_oldcachename = true; } if( fn.FileExists() ) { wxString errMsg; wxLogDebug( wxT( "Load schematic cache library file <%s>" ), GetChars( fn.GetFullPath() ) ); msg = wxT( "Load " ) + fn.GetFullPath(); CMP_LIBRARY* LibCache = CMP_LIBRARY::LoadLibrary( fn, errMsg ); if( LibCache ) { LibCache->SetCache(); msg += wxT( " OK" ); if ( use_oldcachename ) // set the new name { fn.SetName( cachename ); fn.SetExt( SchematicLibraryFileExtension ); LibCache->SetFileName( fn ); } LibCacheExist = true; CMP_LIBRARY::GetLibraryList().push_back( LibCache ); } else { wxString prompt; prompt.Printf( _( "Component library <%s> failed to load.\nError: %s" ), GetChars( fn.GetFullPath() ), GetChars( errMsg ) ); DisplayError( this, prompt ); msg += _( " ->Error" ); } PrintMsg( msg ); } return LibCacheExist; }
// Navy Seals ++ int Pickup_Weapon( gentity_t *ent, gentity_t *other ) { if ( ent->ns_team != other->client->sess.sessionTeam && ent->ns_team != TEAM_FREE ) { // not same team. PrintMsg( other, S_COLOR_RED "This item is not for your team.\n" ); return 0; } if ( !PI_CheckWeapon( other->client->sess.sessionTeam, ent->item->giTag, other->client->pers.nsPC.accuracy, other->client->pers.nsPC.strength, other->client->pers.nsPC.stamina, other->client->pers.nsPC.stealth, qtrue ) ) { PrintMsg( other, S_COLOR_RED "You cannot use this weapon.\n" ); return 0; } BG_PackWeapon( ent->item->giTag, other->client->ps.stats ); if ( ent->item->giAmmoTag == AM_FLASHBANGS ) { // give grenades if ( other->client->ps.ammo[AM_FLASHBANGS] < 2 ) { other->client->ps.ammo[AM_FLASHBANGS]++; } return g_weaponRespawn.integer; } else if ( ent->item->giAmmoTag == AM_GRENADES ) { // give grenades if ( other->client->ps.ammo[AM_GRENADES] < 2 ) { other->client->ps.ammo[AM_GRENADES]++; } return g_weaponRespawn.integer; } else if ( ent->item->giAmmoTag == AM_SMOKE ) { // give grenades if ( other->client->ps.ammo[AM_SMOKE] < 2 ) { other->client->ps.ammo[AM_SMOKE]++; } return g_weaponRespawn.integer; } if ( ent->flags & FL_DROPPED_ITEM ) { other->client->ns.rounds[ent->item->giTag] = ent->count; // has got additional equipment? if ( ent->s.generic1 ) { other->client->ns.weaponmode[ent->item->giTag] = ent->s.generic1; ent->s.generic1 = 0; } } else { // full out clips other->client->ns.rounds[ent->item->giTag] = BG_GetMaxRoundForWeapon( ent->item->giTag ); } // if we're in training / singplayer / dm mode if ( g_gametype.integer < GT_TEAM ) { return g_weaponRespawn.integer; } /* if ( BG_IsPrimary( ent->item->giTag ) ) { int num_clips = 0; // get old primary gitem_t *it_wp; if ( other->client->pers.nsInven.primaryweapon != WP_NONE ) { it_wp = BG_FindItemForWeapon( other->client->pers.nsInven.primaryweapon ); if ( it_wp ) { num_clips = other->client->pers.nsInven.ammo[ it_wp->giAmmoTag ]; other->client->pers.nsInven.ammo[ it_wp->giAmmoTag ] = 0; } } NS_SetPrimary( other, ent->item->giTag ); // get new ammo num_clips = other->client->pers.nsInven.ammo[ ent->item->giAmmoTag ]; if ( ent->item->giTag == WP_M249 ) other->client->pers.nsInven.ammo[ ent->item->giAmmoTag ] = 1; else other->client->pers.nsInven.ammo[ ent->item->giAmmoTag ] = 6; } else if ( BG_IsSecondary( ent->item->giTag ) ) { int num_clips = 0; // get old primary gitem_t *it_wp; if ( other->client->pers.nsInven.secondaryweapon != WP_NONE ) { it_wp = BG_FindItemForWeapon( other->client->pers.nsInven.secondaryweapon ); if ( it_wp ) { num_clips = other->client->pers.nsInven.ammo[ it_wp->giAmmoTag ]; other->client->pers.nsInven.ammo[ it_wp->giAmmoTag ] = 0; } } NS_SetSecondary( other, ent->item->giTag ); // get new ammo num_clips = other->client->pers.nsInven.ammo[ ent->item->giAmmoTag ]; other->client->pers.nsInven.ammo[ ent->item->giAmmoTag ] = 4; } */ return g_weaponRespawn.integer; }
bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl ) { SCH_SCREEN* screen; wxString fullFileName( aFileSet[0] ); wxString msg; SCH_SCREENS screenList; for( screen = screenList.GetFirst(); screen != NULL; screen = screenList.GetNext() ) { if( screen->IsModify() ) break; } if( screen ) { int response = YesNoCancelDialog( this, _( "The current schematic has been modified. Do you wish to save the changes?" ), wxEmptyString, _( "Save and Load" ), _( "Load Without Saving" ) ); if( response == wxID_CANCEL ) { return false; } else if( response == wxID_YES ) { wxCommandEvent dummy; OnSaveProject( dummy ); } } /* if( fullFileName.IsEmpty() && !aIsNew ) { wxFileDialog dlg( this, _( "Open Schematic" ), wxGetCwd(), wxEmptyString, SchematicFileWildcard, wxFD_OPEN | wxFD_FILE_MUST_EXIST ); if( dlg.ShowModal() == wxID_CANCEL ) return false; FullFileName = dlg.GetPath(); } */ wxFileName fn = fullFileName; if( fn.IsRelative() ) { fn.MakeAbsolute(); fullFileName = fn.GetFullPath(); } if( !Pgm().LockFile( fullFileName ) ) { DisplayError( this, _( "This file is already open." ) ); return false; } // Clear the screen before open a new file if( g_RootSheet ) { delete g_RootSheet; g_RootSheet = NULL; } CreateScreens(); screen = GetScreen(); wxLogDebug( wxT( "Loading schematic " ) + fullFileName ); // @todo: this is bad: wxSetWorkingDirectory( fn.GetPath() ); screen->SetFileName( fullFileName ); g_RootSheet->SetFileName( fullFileName ); SetStatusText( wxEmptyString ); ClearMsgPanel(); screen->ClrModify(); #if 0 if( aIsNew ) { /* SCH_SCREEN constructor does this now screen->SetPageSettings( PAGE_INFO( wxT( "A4" ) ) ); */ screen->SetZoom( 32 ); m_LastGridSizeId = screen->SetGrid( ID_POPUP_GRID_LEVEL_50 ); TITLE_BLOCK tb; wxString title; title += NAMELESS_PROJECT; title += wxT( ".sch" ); tb.SetTitle( title ); screen->SetTitleBlock( tb ); GetScreen()->SetFileName( title ); LoadProjectFile( wxEmptyString, true ); Zoom_Automatique( false ); SetSheetNumberAndCount(); m_canvas->Refresh(); return true; } #endif // Reloading configuration. msg.Printf( _( "Ready\nWorking dir: '%s'\n" ), GetChars( wxGetCwd() ) ); PrintMsg( msg ); LoadProjectFile( wxEmptyString, false ); // Clear (if needed) the current active library in libedit because it could be // removed from memory LIB_EDIT_FRAME::EnsureActiveLibExists(); // Delete old caches. CMP_LIBRARY::RemoveCacheLibrary(); if( !wxFileExists( g_RootSheet->GetScreen()->GetFileName() ) ) { Zoom_Automatique( false ); if( aCtl == 0 ) { msg.Printf( _( "File '%s' not found." ), GetChars( g_RootSheet->GetScreen()->GetFileName() ) ); DisplayInfoMessage( this, msg ); } return true; // do not close Eeschema if the file if not found: // we may have to create a new schematic file. } // load the project. bool libCacheExist = LoadCacheLibrary( g_RootSheet->GetScreen()->GetFileName() ); g_RootSheet->SetScreen( NULL ); bool diag = g_RootSheet->Load( this ); SetScreen( m_CurrentSheet->LastScreen() ); UpdateFileHistory( g_RootSheet->GetScreen()->GetFileName() ); // Redraw base screen (ROOT) if necessary. GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId ); Zoom_Automatique( false ); SetSheetNumberAndCount(); m_canvas->Refresh( true ); (void) libCacheExist; (void) diag; // return diag; return true; // do not close Eeschema if the file if not found: // we may have to create a new schematic file. }
/** * Add a message to a queue * * This function provides basic functionnalities to other msg_* functions. * It adds a message to a queue (after having printed all stored messages if it * is full). If the message can't be converted to string in memory, it issues * a warning. */ static void QueueMsg( vlc_object_t *p_this, int i_type, const char *psz_module, const char *psz_format, va_list _args ) { assert (p_this); libvlc_priv_t *priv = libvlc_priv (p_this->p_libvlc); int i_header_size; /* Size of the additionnal header */ vlc_object_t *p_obj; char * psz_str = NULL; /* formatted message string */ char * psz_header = NULL; va_list args; if( p_this->i_flags & OBJECT_FLAGS_QUIET || (p_this->i_flags & OBJECT_FLAGS_NODBG && i_type == VLC_MSG_DBG) ) return; #ifndef __GLIBC__ /* Expand %m to strerror(errno) - only once */ char buf[strlen( psz_format ) + 2001], *ptr; strcpy( buf, psz_format ); ptr = (char*)buf; psz_format = (const char*) buf; for( ;; ) { ptr = strchr( ptr, '%' ); if( ptr == NULL ) break; if( ptr[1] == 'm' ) { char errbuf[2001]; size_t errlen; #ifndef WIN32 strerror_r( errno, errbuf, 1001 ); #else int sockerr = WSAGetLastError( ); if( sockerr ) { strncpy( errbuf, net_strerror( sockerr ), 1001 ); WSASetLastError( sockerr ); } if ((sockerr == 0) || (strcmp ("Unknown network stack error", errbuf) == 0)) strncpy( errbuf, strerror( errno ), 1001 ); #endif errbuf[1000] = 0; /* Escape '%' from the error string */ for( char *percent = strchr( errbuf, '%' ); percent != NULL; percent = strchr( percent + 2, '%' ) ) { memmove( percent + 1, percent, strlen( percent ) + 1 ); } errlen = strlen( errbuf ); memmove( ptr + errlen, ptr + 2, strlen( ptr + 2 ) + 1 ); memcpy( ptr, errbuf, errlen ); break; /* Only once, so we don't overflow */ } /* Looks for conversion specifier... */ do ptr++; while( *ptr && ( strchr( "diouxXeEfFgGaAcspn%", *ptr ) == NULL ) ); if( *ptr ) ptr++; /* ...and skip it */ } #endif /* Convert message to string */ vlc_va_copy( args, _args ); if( vasprintf( &psz_str, psz_format, args ) == -1 ) psz_str = NULL; va_end( args ); if( psz_str == NULL ) { int canc = vlc_savecancel (); /* Do not print half of a message... */ #ifdef __GLIBC__ fprintf( stderr, "main warning: can't store message (%m): " ); #else char psz_err[1001]; #ifndef WIN32 /* we're not using GLIBC, so we are sure that the error description * will be stored in the buffer we provide to strerror_r() */ strerror_r( errno, psz_err, 1001 ); #else strncpy( psz_err, strerror( errno ), 1001 ); #endif psz_err[1000] = '\0'; fprintf( stderr, "main warning: can't store message (%s): ", psz_err ); #endif vlc_va_copy( args, _args ); /* We should use utf8_vfprintf - but it calls malloc()... */ vfprintf( stderr, psz_format, args ); va_end( args ); fputs( "\n", stderr ); vlc_restorecancel (canc); return; } msg_item_t * p_item = malloc (sizeof (*p_item)); if (p_item == NULL) return; /* Uho! */ vlc_gc_init (p_item, msg_Free); p_item->psz_module = p_item->psz_msg = p_item->psz_header = NULL; i_header_size = 0; p_obj = p_this; while( p_obj != NULL ) { char *psz_old = NULL; if( p_obj->psz_header ) { i_header_size += strlen( p_obj->psz_header ) + 4; if( psz_header ) { psz_old = strdup( psz_header ); psz_header = (char*)realloc( psz_header, i_header_size ); snprintf( psz_header, i_header_size , "[%s] %s", p_obj->psz_header, psz_old ); } else { psz_header = (char *)malloc( i_header_size ); snprintf( psz_header, i_header_size, "[%s]", p_obj->psz_header ); } } free( psz_old ); p_obj = p_obj->p_parent; } /* Fill message information fields */ p_item->i_type = i_type; p_item->i_object_id = (uintptr_t)p_this; p_item->psz_object_type = p_this->psz_object_type; p_item->psz_module = strdup( psz_module ); p_item->psz_msg = psz_str; p_item->psz_header = psz_header; PrintMsg( p_this, p_item ); msg_bank_t *p_queue = &QUEUE; vlc_mutex_lock( &p_queue->lock ); #define bank p_queue for (int i = 0; i < bank->i_sub; i++) { msg_subscription_t *sub = bank->pp_sub[i]; if ((sub->end + 1 - sub->begin) % VLC_MSG_QSIZE) { sub->items[sub->end++] = msg_Hold (p_item); if (sub->end == VLC_MSG_QSIZE) sub->end = 0; } else sub->overruns++; } vlc_cond_broadcast (&bank->wait); vlc_mutex_unlock (&bank->lock); msg_Release (p_item); }
glbsp_ret_e GlbspBuildNodes(const nodebuildinfo_t *info, const nodebuildfuncs_t *funcs, volatile nodebuildcomms_t *comms) { char *file_msg; glbsp_ret_e ret = GLBSP_E_OK; cur_info = info; cur_funcs = funcs; cur_comms = comms; cur_comms->total_big_warn = 0; cur_comms->total_small_warn = 0; // clear cancelled flag comms->cancelled = FALSE; // sanity check if (!cur_info->input_file || cur_info->input_file[0] == 0 || !cur_info->output_file || cur_info->output_file[0] == 0) { SetErrorMsg("INTERNAL ERROR: Missing in/out filename !"); return GLBSP_E_BadArgs; } InitDebug(); InitEndian(); if (info->missing_output) PrintMsg("* No output file specified. Using: %s\n\n", info->output_file); if (info->same_filenames) PrintMsg("* Output file is same as input file. Using -loadall\n\n"); // opens and reads directory from the input wad ret = ReadWadFile(cur_info->input_file); if (ret != GLBSP_E_OK) { TermDebug(); return ret; } if (CountLevels() <= 0) { CloseWads(); TermDebug(); SetErrorMsg("No levels found in wad !"); return GLBSP_E_Unknown; } PrintMsg("\n"); PrintVerbose("Creating nodes using tunable factor of %d\n", info->factor); DisplayOpen(DIS_BUILDPROGRESS); DisplaySetTitle("glBSP Build Progress"); file_msg = UtilFormat("File: %s", cur_info->input_file); DisplaySetBarText(2, file_msg); DisplaySetBarLimit(2, CountLevels() * 10); DisplaySetBar(2, 0); UtilFree(file_msg); cur_comms->file_pos = 0; // loop over each level in the wad while (FindNextLevel()) { ret = HandleLevel(); if (ret != GLBSP_E_OK) break; cur_comms->file_pos += 10; DisplaySetBar(2, cur_comms->file_pos); } DisplayClose(); // writes all the lumps to the output wad if (ret == GLBSP_E_OK) { ret = WriteWadFile(cur_info->output_file); // when modifying the original wad, any GWA companion must be deleted if (ret == GLBSP_E_OK && cur_info->same_filenames) DeleteGwaFile(cur_info->output_file); PrintMsg("\n"); PrintMsg("Total serious warnings: %d\n", cur_comms->total_big_warn); PrintMsg("Total minor warnings: %d\n", cur_comms->total_small_warn); ReportFailedLevels(); } // close wads and free memory CloseWads(); TermDebug(); cur_info = NULL; cur_comms = NULL; cur_funcs = NULL; return ret; }
bool WinEDA_SchematicFrame::LoadOneEEFile(BASE_SCREEN *screen, const wxString & FullFileName) /**************************************************************************************/ /* Routine to load an EESchema file. Returns TRUE if file has been loaded (at list partially.) */ { char Line[1024], * SLine; char Name1[256], Name2[256]; int ii, layer, orient, size; wxPoint pos; bool Failed = FALSE; EDA_BaseStruct *Phead, *Pnext; DrawJunctionStruct *ConnectionStruct; DrawPolylineStruct *PolylineStruct; EDA_DrawLineStruct * SegmentStruct; DrawBusEntryStruct * RaccordStruct; DrawMarkerStruct * MarkerStruct; DrawNoConnectStruct * NoConnectStruct; FILE *f; if ( screen == NULL ) return FALSE; if( FullFileName.IsEmpty() ) return FALSE; screen->m_CurrentItem = NULL; LineCount = 1; if ((f = wxFopen(FullFileName, wxT("rt")) ) == NULL) { MsgDiag = _("Failed to open ") + FullFileName; DisplayError(this, MsgDiag); return FALSE; } MsgDiag = _("Loading ") + FullFileName; PrintMsg(MsgDiag); if (fgets(Line, 1024 - 1, f) == NULL || strncmp(Line+9, SCHEMATIC_HEAD_STRING, sizeof(SCHEMATIC_HEAD_STRING) - 1) != 0) { MsgDiag = FullFileName + _(" is NOT EESchema file"); DisplayError(this, MsgDiag); fclose(f); return FALSE; } LineCount++; if(fgets(Line, 1024 - 1, f) == NULL || strncmp(Line, "LIBS:", 5) != 0) { MsgDiag = FullFileName + _(" is NOT EESchema file"); DisplayError(this, MsgDiag); fclose(f); return FALSE; } LoadLayers(f, &LineCount); while (!feof(f) && GetLine(f, Line, &LineCount, sizeof(Line)) != NULL) { SLine = Line; while( (*SLine != ' ' ) && *SLine ) SLine++; switch(Line[0]) { case '$': /* identification de bloc */ if(Line[1] == 'C') { Failed = ReadPartDescr(this, Line, f, screen); } else if(Line[1] == 'S') { Failed = ReadSheetDescr(this, Line, f, screen); } else if(Line[1] == 'D') { Failed = ReadSchemaDescr(this, Line, f, screen); } break; case 'L': /* Its a library item. */ Failed = ReadPartDescr(this, Line, f, screen); break; /* Fin lecture 1 composant */ case 'W': /* Its a Segment (WIRE or BUS) item. */ if( sscanf(SLine, "%s %s", Name1, Name2) != 2 ) { MsgDiag.Printf( wxT("EESchema file Segment struct error at line %d, aborted"), LineCount); Failed = TRUE; break; } layer = LAYER_NOTES; if( Name1[0] == 'W' ) layer = LAYER_WIRE; if( Name1[0] == 'B' ) layer = LAYER_BUS; SegmentStruct = new EDA_DrawLineStruct(wxPoint(0,0),layer); LineCount++; if (fgets(Line, 256 - 1, f) == NULL || sscanf(Line, "%d %d %d %d ", &SegmentStruct->m_Start.x,&SegmentStruct->m_Start.y, &SegmentStruct->m_End.x,&SegmentStruct->m_End.y) != 4 ) { MsgDiag.Printf( wxT("EESchema file Segment struct error at line %d, aborted"), LineCount); Failed = TRUE; delete SegmentStruct; break; } if (!Failed) { SegmentStruct->Pnext = screen->EEDrawList; screen->EEDrawList = (EDA_BaseStruct *) SegmentStruct; } break; case 'E': /* Its a Raccord (WIRE or BUS) item. */ if( sscanf(SLine, "%s %s", Name1, Name2) != 2 ) { MsgDiag.Printf( wxT("EESchema file Raccord struct error at line %d, aborted"), LineCount); Failed = TRUE; break; } ii = WIRE_TO_BUS; if( Name1[0] == 'B' ) ii = BUS_TO_BUS; RaccordStruct = new DrawBusEntryStruct(wxPoint(0,0), '\\', ii); LineCount++; if (fgets(Line, 256 - 1, f) == NULL || sscanf(Line, "%d %d %d %d ", &RaccordStruct->m_Pos.x,&RaccordStruct->m_Pos.y, &RaccordStruct->m_Size.x,&RaccordStruct->m_Size.y) != 4 ) { MsgDiag.Printf( wxT("EESchema file Raccord struct error at line %d, aborted"), LineCount); Failed = TRUE; delete RaccordStruct; break; } if (!Failed) { RaccordStruct->m_Size.x -= RaccordStruct->m_Pos.x; RaccordStruct->m_Size.y -= RaccordStruct->m_Pos.y; RaccordStruct->Pnext = screen->EEDrawList; screen->EEDrawList = RaccordStruct; } break; case 'P': /* Its a polyline item. */ if (sscanf(SLine, "%s %s %d", Name1, Name2, &ii) != 3 ) { MsgDiag.Printf( wxT("EESchema file polyline struct error at line %d, aborted"), LineCount); Failed = TRUE; break; } layer = LAYER_NOTES; if( Name2[0] == 'W' ) layer = LAYER_WIRE; if( Name2[0] == 'B' ) layer = LAYER_BUS; PolylineStruct = new DrawPolylineStruct(layer); PolylineStruct->m_NumOfPoints = ii; PolylineStruct->m_Points = (int *) MyZMalloc(sizeof(int) * 2 * PolylineStruct->m_NumOfPoints); for (ii = 0; ii < PolylineStruct->m_NumOfPoints; ii++) { LineCount++; if (fgets(Line, 256 - 1, f) == NULL || sscanf(Line, "%d %d", &PolylineStruct->m_Points[ii*2], &PolylineStruct->m_Points[ii*2+1]) != 2) { MsgDiag.Printf( wxT("EESchema file polyline struct error at line %d, aborted"), LineCount); Failed = TRUE; delete PolylineStruct; break; } } if (!Failed) { PolylineStruct->Pnext = screen->EEDrawList; screen->EEDrawList = (EDA_BaseStruct *) PolylineStruct; } break; case 'C': /* Its a connection item. */ ConnectionStruct = new DrawJunctionStruct(wxPoint(0,0)); if (sscanf(SLine, "%s %d %d", Name1, &ConnectionStruct->m_Pos.x, &ConnectionStruct->m_Pos.y) != 3) { MsgDiag.Printf( wxT("EESchema file connection struct error at line %d, aborted"), LineCount); Failed = TRUE; delete ConnectionStruct; } else { ConnectionStruct->Pnext = screen->EEDrawList; screen->EEDrawList = ConnectionStruct; } break; case 'N': /* Its a NoConnect item. */ if (sscanf(SLine, "%s %d %d", Name1, &pos.x, &pos.y) != 3) { MsgDiag.Printf( wxT("EESchema file NoConnect struct error at line %d, aborted"), LineCount); Failed = TRUE; } else { NoConnectStruct = new DrawNoConnectStruct(pos); NoConnectStruct->Pnext = screen->EEDrawList; screen->EEDrawList = NoConnectStruct; } break; case 'K': /* Its a MarKer item. */ if (sscanf(SLine, "%s %d %d", Name1, &pos.x, &pos.y) != 3) { MsgDiag.Printf( wxT("EESchema file marker struct error line %d, aborted"), LineCount); Failed = TRUE; } else { char * text; char BufLine[1024]; MarkerStruct = new DrawMarkerStruct(pos,wxEmptyString); ii = ReadDelimitedText(BufLine, Line, 256 ); MarkerStruct->m_Type = (TypeMarker)((Name1[0] & 255) - 'A'); if( MarkerStruct->m_Type < 0 ) MarkerStruct->m_Type = MARQ_UNSPEC; if ( ii ) MarkerStruct->m_Comment = CONV_FROM_UTF8(BufLine); text = strstr(Line," F="); if (text) { sscanf(text+3, "%X", &ii); MarkerStruct->m_MarkFlags = ii; } MarkerStruct->Pnext = screen->EEDrawList; screen->EEDrawList = MarkerStruct; } break; case 'T': /* Its a text item. */ { EDA_BaseStruct * Struct = NULL; *Name1 = *Name2 = 0; ii = sscanf(SLine, "%s %d %d %d %d %s", Name1, &pos.x, &pos.y, &orient, &size, Name2); if( ii < 4 ) { MsgDiag.Printf( wxT("EESchema file text struct error line %d, aborted"), LineCount); Failed = TRUE; } else if( fgets(Line, 256 - 1, f) == NULL ) { LineCount++; MsgDiag.Printf( wxT("EESchema file text struct error line %d (No text), aborted"), LineCount); Failed = TRUE; } else { LineCount++; if( size == 0 ) size = DEFAULT_SIZE_TEXT; char * text = strtok(Line, "\n\r"); if ( text == NULL ) break; if( Name1[0] == 'L' ) { DrawLabelStruct * TextStruct = new DrawLabelStruct(pos, CONV_FROM_UTF8(text)); TextStruct->m_Size.x = TextStruct->m_Size.y = size; TextStruct->m_Orient = orient; Struct = (EDA_BaseStruct*)TextStruct; } else if( Name1[0] == 'G' ) { DrawGlobalLabelStruct * TextStruct = new DrawGlobalLabelStruct(pos, CONV_FROM_UTF8(text)); Struct = (EDA_BaseStruct*)TextStruct; TextStruct->m_Size.x = TextStruct->m_Size.y = size; TextStruct->m_Orient = orient; if( stricmp(Name2,SheetLabelType[NET_OUTPUT]) == 0 ) TextStruct->m_Shape = NET_OUTPUT; if( stricmp(Name2,SheetLabelType[NET_BIDI]) == 0 ) TextStruct->m_Shape = NET_BIDI; if( stricmp(Name2,SheetLabelType[NET_TRISTATE]) == 0 ) TextStruct->m_Shape = NET_TRISTATE; if( stricmp(Name2,SheetLabelType[NET_UNSPECIFIED]) == 0 ) TextStruct->m_Shape = NET_UNSPECIFIED; } else { DrawTextStruct * TextStruct = new DrawTextStruct(pos, CONV_FROM_UTF8(text)); TextStruct->m_Size.x = TextStruct->m_Size.y = size; TextStruct->m_Orient = orient; Struct = (EDA_BaseStruct*)TextStruct; } if (Struct ) { Struct->Pnext = screen->EEDrawList; screen->EEDrawList = Struct; } } break; } default: Failed = FALSE; MsgDiag.Printf( wxT("EESchema file undef structdef at line %d, aborted"), LineCount); break; } if (Failed) { DisplayError(this, MsgDiag); break; } } /* EEDrawList was constructed in reverse order - reverse it back: */ Phead = NULL; while (screen->EEDrawList) { Pnext = screen->EEDrawList; screen->EEDrawList = screen->EEDrawList->Pnext; Pnext->Pnext = Phead; Phead = Pnext; } screen->EEDrawList = Phead; fclose(f); TestDanglingEnds(screen->EEDrawList, NULL); return TRUE; /* Although it may be that file is only partially loaded. */ }
/* ============== Team_DroppedFlagThink ============== */ int Team_TouchOurFlag( gentity_t *ent, gentity_t *other, int team ) { int i; gentity_t *player; gclient_t *cl = other->client; int enemy_flag; #ifdef MISSIONPACK if( g_gametype.integer == GT_1FCTF ) { enemy_flag = PW_NEUTRALFLAG; } else { #endif if (cl->sess.sessionTeam == TEAM_RED) { enemy_flag = PW_BLUEFLAG; } else { enemy_flag = PW_REDFLAG; } if ( ent->flags & FL_DROPPED_ITEM ) { // hey, it's not home. return it by teleporting it back PrintMsg( NULL, "%s" S_COLOR_WHITE " returned the %s flag!\n", cl->pers.netname, TeamName(team)); AddScore(other, ent->r.currentOrigin, CTF_RECOVERY_BONUS); other->client->pers.teamState.flagrecovery++; other->client->pers.teamState.lastreturnedflag = level.time; //ResetFlag will remove this entity! We must return zero Team_ReturnFlagSound(Team_ResetFlag(team), team); return 0; } #ifdef MISSIONPACK } #endif // the flag is at home base. if the player has the enemy // flag, he's just won! if (!cl->ps.powerups[enemy_flag]) return 0; // We don't have the flag #ifdef MISSIONPACK if( g_gametype.integer == GT_1FCTF ) { PrintMsg( NULL, "%s" S_COLOR_WHITE " captured the flag!\n", cl->pers.netname ); } else { #endif PrintMsg( NULL, "%s" S_COLOR_WHITE " captured the %s flag!\n", cl->pers.netname, TeamName(OtherTeam(team))); #ifdef MISSIONPACK } #endif cl->ps.powerups[enemy_flag] = 0; teamgame.last_flag_capture = level.time; teamgame.last_capture_team = team; // Increase the team's score AddTeamScore(ent->s.pos.trBase, other->client->sess.sessionTeam, 1); Team_ForceGesture(other->client->sess.sessionTeam); other->client->pers.teamState.captures++; // add the sprite over the player's head other->client->ps.eFlags &= ~(EF_AWARD_IMPRESSIVE | EF_AWARD_EXCELLENT | EF_AWARD_GAUNTLET | EF_AWARD_ASSIST | EF_AWARD_DEFEND | EF_AWARD_CAP ); other->client->ps.eFlags |= EF_AWARD_CAP; other->client->rewardTime = level.time + REWARD_SPRITE_TIME; other->client->ps.persistant[PERS_CAPTURES]++; // other gets another 10 frag bonus AddScore(other, ent->r.currentOrigin, CTF_CAPTURE_BONUS); Team_CaptureFlagSound( ent, team ); // Ok, let's do the player loop, hand out the bonuses for (i = 0; i < g_maxclients.integer; i++) { player = &g_entities[i]; // also make sure we don't award assist bonuses to the flag carrier himself. if (!player->inuse || player == other) continue; if (player->client->sess.sessionTeam != cl->sess.sessionTeam) { player->client->pers.teamState.lasthurtcarrier = -5; } else if (player->client->sess.sessionTeam == cl->sess.sessionTeam) { #ifdef MISSIONPACK AddScore(player, ent->r.currentOrigin, CTF_TEAM_BONUS); #endif // award extra points for capture assists if (player->client->pers.teamState.lastreturnedflag + CTF_RETURN_FLAG_ASSIST_TIMEOUT > level.time) { AddScore (player, ent->r.currentOrigin, CTF_RETURN_FLAG_ASSIST_BONUS); other->client->pers.teamState.assists++; player->client->ps.persistant[PERS_ASSIST_COUNT]++; // add the sprite over the player's head player->client->ps.eFlags &= ~(EF_AWARD_IMPRESSIVE | EF_AWARD_EXCELLENT | EF_AWARD_GAUNTLET | EF_AWARD_ASSIST | EF_AWARD_DEFEND | EF_AWARD_CAP ); player->client->ps.eFlags |= EF_AWARD_ASSIST; player->client->rewardTime = level.time + REWARD_SPRITE_TIME; } if (player->client->pers.teamState.lastfraggedcarrier + CTF_FRAG_CARRIER_ASSIST_TIMEOUT > level.time) { AddScore(player, ent->r.currentOrigin, CTF_FRAG_CARRIER_ASSIST_BONUS); other->client->pers.teamState.assists++; player->client->ps.persistant[PERS_ASSIST_COUNT]++; // add the sprite over the player's head player->client->ps.eFlags &= ~(EF_AWARD_IMPRESSIVE | EF_AWARD_EXCELLENT | EF_AWARD_GAUNTLET | EF_AWARD_ASSIST | EF_AWARD_DEFEND | EF_AWARD_CAP ); player->client->ps.eFlags |= EF_AWARD_ASSIST; player->client->rewardTime = level.time + REWARD_SPRITE_TIME; } } } Team_ResetFlags(); CalculateRanks(); return 0; // Do not respawn this automatically }
int WinEDA_SchematicFrame::LoadOneEEProject(const wxString & FileName, bool IsNew) /********************************************************************************/ /* Routine de chargement d'un projet ( schema principal "Root" et ses sous schemas ( hierarchie ) */ { BASE_SCREEN *screen, * NextScreen; EDA_BaseStruct *EEDrawList ; wxString FullFileName, msg; bool LibCacheExist = FALSE; screen = ScreenSch ; while( screen ) { if(screen->IsModify()) break; screen = screen->Next(); } if ( screen ) { if( ! IsOK(this, _("Clear Schematic Hierarchy (modified!)?")) ) return FALSE; if ( ScreenSch->m_FileName != g_DefaultSchematicFileName ) SetLastProject(ScreenSch->m_FileName); } screen = ScreenSch ; FullFileName = FileName; if( (FullFileName.IsEmpty() ) && !IsNew ) { wxString mask = wxT("*") + g_SchExtBuffer; FullFileName = EDA_FileSelector( _("Schematic files:"), wxEmptyString, /* Chemin par defaut */ wxEmptyString, /* nom fichier par defaut */ g_SchExtBuffer, /* extension par defaut */ mask, /* Masque d'affichage */ this, wxOPEN, TRUE ); if ( FullFileName.IsEmpty() ) return ( FALSE ); } if( ClearProjectDrawList((SCH_SCREEN*) screen) == FALSE ) return(1); m_CurrentScreen = screen = ActiveScreen = ScreenSch; screen->m_CurrentItem = NULL; wxSetWorkingDirectory(wxPathOnly(FullFileName) ); m_CurrentScreen->m_FileName = FullFileName; Affiche_Message(wxEmptyString); MsgPanel->EraseMsgBox(); memset( &g_EESchemaVar,0, sizeof(g_EESchemaVar) ); m_CurrentScreen->ClrModify(); m_CurrentScreen->Pnext = NextScreen = NULL; if( IsNew ) { screen->m_CurrentSheet = &g_Sheet_A4; screen->SetZoom(32); screen->m_SheetNumber = screen->m_NumberOfSheet = 1; screen->m_Title = wxT("noname.sch"); m_CurrentScreen->m_FileName = screen->m_Title; screen->m_Company.Empty(); screen->m_Commentaire1.Empty(); screen->m_Commentaire2.Empty(); screen->m_Commentaire3.Empty(); screen->m_Commentaire4.Empty(); Read_Config(wxEmptyString, TRUE); Zoom_Automatique(TRUE); ReDrawPanel(); return (1); } // Rechargement de la configuration: msg = _("Ready\nWorking dir: \n") + wxGetCwd(); PrintMsg(msg); Read_Config(wxEmptyString, FALSE); // Delete old caches. LibraryStruct *nextlib, *lib = g_LibraryList; for (; lib != NULL; lib = nextlib ) { nextlib = lib->m_Pnext; if ( lib->m_IsLibCache ) FreeCmpLibrary(this, lib->m_Name); } if( IsNew ) { ReDrawPanel(); return (1); } // Loading the project library cache wxString FullLibName; wxString shortfilename; wxSplitPath(ScreenSch->m_FileName, NULL, &shortfilename, NULL); FullLibName << wxT(".") << STRING_DIR_SEP << shortfilename << wxT(".cache") << g_LibExtBuffer; if ( wxFileExists(FullLibName) ) { wxString libname; libname = FullLibName; ChangeFileNameExt(libname,wxEmptyString); msg = wxT("Load ") + FullLibName; LibraryStruct *LibCache = LoadLibraryName(this, FullLibName, libname); if ( LibCache ) { LibCache->m_IsLibCache = TRUE; msg += wxT(" OK"); } else msg += wxT(" ->Error"); PrintMsg( msg ); LibCacheExist = TRUE; } if ( ! wxFileExists(screen->m_FileName) && !LibCacheExist) // Nouveau projet prpbablement { msg.Printf( _("File %s not found (new project ?)"), screen->m_FileName.GetData() ); DisplayInfo(this, msg, 20); return (-1); } if( LoadOneEEFile(screen, screen->m_FileName) == FALSE) return (0); /* Chargement des sous feuilles */ while(screen) { EEDrawList = screen->EEDrawList; while(EEDrawList) { if( EEDrawList->m_StructType == DRAW_SHEET_STRUCT_TYPE) { #undef STRUCT #define STRUCT ((DrawSheetStruct*)EEDrawList) int timestamp = STRUCT->m_TimeStamp; if(timestamp == 0 ) { timestamp = GetTimeStamp(); STRUCT->m_TimeStamp = timestamp; } if( screen->Pnext == NULL) /* 1ere Sheet */ { screen->Pnext = NextScreen = CreateNewScreen(this, (SCH_SCREEN*)screen,timestamp); } else { NextScreen->Pnext = CreateNewScreen(this, (SCH_SCREEN*)NextScreen, timestamp); NextScreen = (BASE_SCREEN*)NextScreen->Pnext; } STRUCT->m_Son = NextScreen; NextScreen->m_Parent = EEDrawList; if( ! STRUCT->m_Field[SHEET_FILENAME].m_Text.IsEmpty() ) { NextScreen->m_FileName = STRUCT->m_Field[SHEET_FILENAME].m_Text; if( LoadOneEEFile(NextScreen, NextScreen->m_FileName) == TRUE ) { ActiveScreen = (SCH_SCREEN*) NextScreen; } } else DisplayError(this, _("No FileName in SubSheet")); } EEDrawList = EEDrawList->Pnext; } screen = (BASE_SCREEN*)screen->Pnext; } /* Reaffichage ecran de base (ROOT) si necessaire */ screen = ActiveScreen = ScreenSch; Zoom_Automatique(FALSE); return (1); }
void KICAD_MANAGER_FRAME::OnArchiveFiles( wxCommandEvent& event ) { // List of file extensions to save. static const wxChar* extentionList[] = { wxT( "*.sch" ), wxT( "*.lib" ), wxT( "*.mod" ), wxT( "*.cmp" ), wxT( "*.brd" ), wxT( "*.kicad_pcb" ), wxT( "*.gbr" ), wxT( "*.pos" ), wxT( "*.net" ), wxT( "*.pro" ), wxT( "*.drl" ), wxT( "*.py" ), wxT( "*.pdf" ), wxT( "*.txt" ), wxT( "*.dcm" ), wxT( "*.kicad_wks" ), }; wxString msg; wxFileName fileName = GetProjectFileName(); wxString oldCwd = wxGetCwd(); fileName.SetExt( wxT( "zip" ) ); wxFileDialog dlg( this, _( "Archive Project Files" ), fileName.GetPath(), fileName.GetFullName(), ZipFileWildcard, wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); if( dlg.ShowModal() == wxID_CANCEL ) return; wxFileName zip = dlg.GetPath(); wxString currdirname = fileName.GetPathWithSep(); wxDir dir( currdirname ); if( !dir.IsOpened() ) return; wxSetWorkingDirectory( currdirname ); // Prepare the zip file wxString zipfilename = zip.GetFullPath(); wxFFileOutputStream ostream( zipfilename ); wxZipOutputStream zipstream( ostream ); // Build list of filenames to put in zip archive wxString currFilename; wxArrayString files; for( unsigned ii = 0; ii < DIM( extentionList ); ii++ ) wxDir::GetAllFiles( currdirname, &files, extentionList[ii] ); files.Sort(); int zipBytesCnt = 0; for( unsigned ii = 0; ii < files.GetCount(); ii++ ) { wxFileSystem fsfile; wxFileName curr_fn( files[ii] ); curr_fn.MakeRelativeTo( currdirname ); currFilename = curr_fn.GetFullPath(); msg.Printf( _( "Archive file <%s>" ), GetChars( currFilename ) ); PrintMsg( msg ); // Read input file and add it to the zip file: wxFSFile* infile = fsfile.OpenFile( currFilename ); if( infile ) { zipstream.PutNextEntry( currFilename, infile->GetModificationTime() ); infile->GetStream()->Read( zipstream ); zipstream.CloseEntry(); int zippedsize = zipstream.GetSize() - zipBytesCnt; zipBytesCnt = zipstream.GetSize(); PrintMsg( wxT(" ") ); msg.Printf( _( "(%lu bytes, compressed %d bytes)\n" ), (unsigned long)infile->GetStream()->GetSize(), zippedsize ); PrintMsg( msg ); delete infile; } else PrintMsg( _( " >>Error\n" ) ); } zipBytesCnt = ostream.GetSize(); if( zipstream.Close() ) { msg.Printf( _( "\nZip archive <%s> created (%d bytes)" ), GetChars( zipfilename ), zipBytesCnt ); PrintMsg( msg ); PrintMsg( wxT( "\n** end **\n" ) ); } else { msg.Printf( wxT( "Unable to create archive <%s>, abort\n" ), GetChars( zipfilename ) ); PrintMsg( msg ); } wxSetWorkingDirectory( oldCwd ); }
//------------------------------------------------------------------------------------------------- int CFaceClusters::FaceClusters(int *iface, float th, float tl, int metric) { float *fmat = new float[num*num]; float *fvec = new float[num]; bool *bvec = new bool[num]; int *hist = new int[num]; int i, j, k; for(i=0; i<num; i++) { float *xi = dat+i*dim; for(j=0; j<i; j++) { float *xj = dat+j*dim; float f = GetSimilar(dim, xi, xj, metric); fmat[i*num+j] = fmat[j*num+i] = f;//max(0, f-0.5f); } fmat[i*num+i] = 0; } for(i=0; i<num; i++) { float sum = 0; for(j=0; j<num; j++) if(fmat[i*num+j]>th) sum++; //for(j=0; j<num; j++) sum += fmat[i*num+j]; // 1 fvec[i] = sum; iface[i] = -1; } k = 1; while(true) { float fmax = -1; for(i=0; i<num; i++) if(iface[i]==-1 && fmax<fvec[i]) fmax = fvec[i], j = i; if(fmax==-1) break; //if(fmax<t) printf("%f\n", fmax); //iface[j] = k; if(fmax>0) { iface[j] = k; // find neighbors for(i=0; i<num; i++) if(iface[i]==-1 && fmat[j*num+i]>th) iface[i] = k; // remove unbelievable for(i=0; i<num; i++) { bvec[i] = false; if(i!=j && iface[i]==k) { int num1 = 0, num2 = 0; float *p = fmat+i*num; for(int l=0; l<num; l++) { if(p[l]>th) { num1++; if(iface[l]==k) num2++; } } if(num2<0.6*num1) bvec[i] = true; } } for(i=0; i<num; i++) if(bvec[i]) iface[i] = -1; int numk = 0; for(i=0; i<num; i++) if(iface[i]==k) numk++; if(numk>1) k++; else iface[j] = 0; } else iface[j] = 0; } for(k=0; k<num; k++) { if(iface[k]==0) { float fmax = 0, *p = fmat+k*num; int i0 = 0; for(i=0; i<num; i++) { if(iface[i]==0) continue; if(fmax<p[i]) fmax = p[i], i0 = i; } if(fmax>tl && fvec[k]<=1) iface[k] = iface[i0]; } } int maxid = 0; for(i=0; i<num; i++) if(maxid<iface[i]) maxid = iface[i]; for(i=0; i<num; i++) if(iface[i]==0) iface[i] = maxid++; PrintMsg(num, fmat, fvec, iface); delete []fmat; delete []fvec; delete []bvec; delete []hist; return k-1; }
/* ================ Team_FragBonuses Calculate the bonuses for flag defense, flag carrier defense, etc. Note that bonuses are not cumlative. You get one, they are in importance order. ================ */ void Team_FragBonuses( gentity_t *targ, gentity_t *inflictor, gentity_t *attacker ) { int i; gentity_t *ent; int flag_pw, enemy_flag_pw; int otherteam; gentity_t *flag, *carrier = NULL; const char *c; vec3_t v1, v2; int team; // no bonus for fragging yourself if ( !targ->client || !attacker->client || targ == attacker ) { return; } team = targ->client->sess.sessionTeam; otherteam = OtherTeam( targ->client->sess.sessionTeam ); if ( otherteam < 0 ) { return; // whoever died isn't on a team } // same team, if the flag at base, check to he has the enemy flag if ( team == TEAM_RED ) { flag_pw = PW_REDFLAG; enemy_flag_pw = PW_BLUEFLAG; } else { flag_pw = PW_BLUEFLAG; enemy_flag_pw = PW_REDFLAG; } // did the attacker frag the flag carrier? if ( targ->client->ps.powerups[enemy_flag_pw] ) { attacker->client->pers.teamState.lastfraggedcarrier = level.time; AddScore( attacker, CTF_FRAG_CARRIER_BONUS ); attacker->client->pers.teamState.fragcarrier++; PrintMsg( NULL, "%s" S_COLOR_WHITE " fragged %s's flag carrier!\n", attacker->client->pers.netname, TeamName( team ) ); // the target had the flag, clear the hurt carrier // field on the other team for ( i = 0; i < g_maxclients.integer; i++ ) { ent = g_entities + i; if ( ent->inuse && ent->client->sess.sessionTeam == otherteam ) { ent->client->pers.teamState.lasthurtcarrier = 0; } } return; } if ( targ->client->pers.teamState.lasthurtcarrier && level.time - targ->client->pers.teamState.lasthurtcarrier < CTF_CARRIER_DANGER_PROTECT_TIMEOUT && !attacker->client->ps.powerups[flag_pw] ) { // attacker is on the same team as the flag carrier and // fragged a guy who hurt our flag carrier AddScore( attacker, CTF_CARRIER_DANGER_PROTECT_BONUS ); attacker->client->pers.teamState.carrierdefense++; team = attacker->client->sess.sessionTeam; PrintMsg( NULL, "%s" S_COLOR_WHITE " defends %s's flag carrier against an agressive enemy\n", attacker->client->pers.netname, TeamName( team ) ); return; } // flag and flag carrier area defense bonuses // we have to find the flag and carrier entities // find the flag switch ( attacker->client->sess.sessionTeam ) { case TEAM_RED: c = "team_CTF_redflag"; break; case TEAM_BLUE: c = "team_CTF_blueflag"; break; default: return; } flag = NULL; while ( ( flag = G_Find( flag, FOFS( classname ), c ) ) != NULL ) { if ( !( flag->flags & FL_DROPPED_ITEM ) ) { break; } } if ( !flag ) { return; // can't find attacker's flag } // find attacker's team's flag carrier for ( i = 0; i < g_maxclients.integer; i++ ) { carrier = g_entities + i; if ( carrier->inuse && carrier->client->ps.powerups[flag_pw] ) { break; } carrier = NULL; } // ok we have the attackers flag and a pointer to the carrier // check to see if we are defending the base's flag VectorSubtract( targ->s.origin, flag->s.origin, v1 ); VectorSubtract( attacker->s.origin, flag->s.origin, v2 ); if ( ( VectorLength( v1 ) < CTF_TARGET_PROTECT_RADIUS || VectorLength( v2 ) < CTF_TARGET_PROTECT_RADIUS || CanDamage( flag, targ->s.origin ) || CanDamage( flag, attacker->s.origin ) ) && attacker->client->sess.sessionTeam != targ->client->sess.sessionTeam ) { // we defended the base flag AddScore( attacker, CTF_FLAG_DEFENSE_BONUS ); attacker->client->pers.teamState.basedefense++; if ( !flag->r.contents ) { PrintMsg( NULL, "%s" S_COLOR_WHITE " defends the %s base.\n", attacker->client->pers.netname, TeamName( attacker->client->sess.sessionTeam ) ); } else { PrintMsg( NULL, "%s" S_COLOR_WHITE " defends the %s flag.\n", attacker->client->pers.netname, TeamName( attacker->client->sess.sessionTeam ) ); } return; } if ( carrier && carrier != attacker ) { VectorSubtract( targ->s.origin, carrier->s.origin, v1 ); VectorSubtract( attacker->s.origin, carrier->s.origin, v1 ); if ( VectorLength( v1 ) < CTF_ATTACKER_PROTECT_RADIUS || VectorLength( v2 ) < CTF_ATTACKER_PROTECT_RADIUS || CanDamage( carrier, targ->s.origin ) || CanDamage( carrier, attacker->s.origin ) ) { AddScore( attacker, CTF_CARRIER_PROTECT_BONUS ); attacker->client->pers.teamState.carrierdefense++; PrintMsg( NULL, "%s" S_COLOR_WHITE " defends the %s's flag carrier.\n", attacker->client->pers.netname, TeamName( attacker->client->sess.sessionTeam ) ); return; } } }
int main( int argc, char **argv ) /********************************/ { int rc; char *wcl_env; char *p; char *q; char *Cmd; /* command line parameters */ #ifndef __WATCOMC__ _argc = argc; _argv = argv; #endif CC_Opts[0] = '\0'; Switch_Chars[0] = '-'; Switch_Chars[1] = _dos_switch_char(); Switch_Chars[2] = '\0'; MemInit(); ProcMemInit(); Word = MemAlloc( MAX_CMD ); Cmd = MemAlloc( MAX_CMD * 2 ); /* enough for cmd line & wcl variable */ /* add wcl environment variable to Cmd */ /* unless /y is specified in either Cmd or wcl */ wcl_env = getenv( WCLENV ); if( wcl_env != NULL ) { strcpy( Cmd, wcl_env ); strcat( Cmd, " " ); p = Cmd + strlen( Cmd ); getcmd( p ); q = Cmd; while( (q = strpbrk( q, Switch_Chars )) != NULL ) { if( tolower( *(++q) ) == 'y' ) { getcmd( Cmd ); p = Cmd; break; } } } else { getcmd( Cmd ); p = Cmd; } p = SkipSpaces( p ); if( *p == '\0' || p[0] == '?' && ( p[1] == '\0' || p[1] == ' ' ) || p[0] == '-' && p[1] == '?' ) { Usage(); rc = 1; } else { errno = 0; /* Standard C does not require fopen failure to set errno */ if( (Fp = fopen( TEMPFILE, "w" )) == NULL ) { /* Message before banner decision as '@' option uses Fp in Parse() */ PrintMsg( WclMsgs[UNABLE_TO_OPEN_TEMPORARY_FILE], TEMPFILE, strerror( errno ) ); rc = 1; } else { initialize_Flags(); rc = Parse( Cmd ); if( rc == 0 ) { if( !Flags.be_quiet ) { print_banner(); } rc = CompLink(); } if( rc == 1 ) { fclose( Fp ); } if( Link_Name != NULL ) { if( fname_cmp( Link_Name, TEMPFILE ) != 0 ) { remove( Link_Name ); rename( TEMPFILE, Link_Name ); } } else { remove( TEMPFILE ); } } } ProcMemFini(); MemFree( Cmd ); MemFree( Word ); MemFini(); return( rc == 0 ? 0 : 1 ); }