本文整理汇总了C++中std::list::pop_back方法的典型用法代码示例。如果您正苦于以下问题:C++ list::pop_back方法的具体用法?C++ list::pop_back怎么用?C++ list::pop_back使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::list
的用法示例。
在下文中一共展示了list::pop_back方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: move_items
// I'd love to have this not duplicate so much code from Pickup::pick_one_up(),
// but I don't see a clean way to do that.
static void move_items( const tripoint &src, bool from_vehicle,
const tripoint &dest, bool to_vehicle,
std::list<int> &indices, std::list<int> &quantities )
{
tripoint source = src + g->u.pos();
tripoint destination = dest + g->u.pos();
int s_cargo, d_cargo; // oui oui, mon frere
s_cargo = d_cargo = -1;
vehicle *s_veh, *d_veh; // 2diva4me
s_veh = d_veh = nullptr;
// load vehicle information if requested
if(from_vehicle == true) {
s_veh = g->m.veh_at(source, s_cargo);
assert(s_veh != nullptr);
s_cargo = s_veh->part_with_feature(s_cargo, "CARGO", false);
assert(s_cargo >= 0);
}
if(to_vehicle == true) {
d_veh = g->m.veh_at(destination, d_cargo);
assert(d_veh != nullptr);
d_cargo = d_veh->part_with_feature(d_cargo, "CARGO", false);
assert(d_cargo >= 0);
}
std::vector<item> dropped_items;
std::vector<item> dropped_worn;
while( g->u.moves > 0 && !indices.empty() ) {
int index = indices.back();
int quantity = quantities.back();
indices.pop_back();
quantities.pop_back();
item *temp_item = nullptr;
temp_item = (from_vehicle == true) ?
g->m.item_from(s_veh, s_cargo, index) :
g->m.item_from(source, index);
if( temp_item == nullptr ) {
continue; // No such item.
}
item leftovers = *temp_item;
if( quantity != 0 && temp_item->count_by_charges() ) {
// Reinserting leftovers happens after item removal to avoid stacking issues.
leftovers.charges = temp_item->charges - quantity;
if( leftovers.charges > 0 ) {
temp_item->charges = quantity;
}
} else {
leftovers.charges = 0;
}
// Check that we can pick it up.
if( !temp_item->made_of(LIQUID) ) {
// Is it too bulky? We'll have to use our hands, then.
if( !g->u.can_pickVolume(temp_item->volume()) && g->u.is_armed() ) {
g->u.moves -= 20; // Pretend to be unwielding our gun.
}
// Is it too heavy? It'll take a while...
if( !g->u.can_pickWeight(temp_item->weight(), true) ) {
int overweight = temp_item->weight() - (g->u.weight_capacity() - g->u.weight_carried());
// ...like one move cost per 100 grams over your leftover carry capacity.
g->u.moves -= int(overweight / 100);
}
// Drop it first since we're going to delete the original.
dropped_items.push_back( *temp_item );
// I changed this to use a tripoint as an argument, but the function is not 3D yet.
g->drop( dropped_items, dropped_worn, 0, destination, to_vehicle );
// Remove from map or vehicle.
if(from_vehicle == true) {
s_veh->remove_item(s_cargo, index);
} else {
g->m.i_rem(source, index);
}
g->u.moves -= 100;
}
// If we didn't pick up a whole stack, put the remainder back where it came from.
if( leftovers.charges > 0 ) {
bool to_map = !from_vehicle;
if( !to_map ) {
to_map = !s_veh->add_item(s_cargo, leftovers);
}
if( to_map ){
g->m.add_item_or_charges(source, leftovers);
}
}
//.........这里部分代码省略.........
示例2: AddTriangle_R
void EarClipper::AddTriangle_R(std::vector<const FVector2*>& triangles,
const FVector2* trianglePoint1, std::list<const FVector2*>& collinearPoints1,
const FVector2* trianglePoint2, std::list<const FVector2*>& collinearPoints2,
const FVector2* trianglePoint3, std::list<const FVector2*>& collinearPoints3)
{
if (collinearPoints1.empty() && collinearPoints2.empty() && collinearPoints3.empty())
{
triangles.push_back(trianglePoint1);
triangles.push_back(trianglePoint2);
triangles.push_back(trianglePoint3);
}
else
{
if (!collinearPoints1.empty())
{
bool point3HasCollinearVertices = !collinearPoints3.empty();
const FVector2* anchorPoint = point3HasCollinearVertices ? collinearPoints3.back() : trianglePoint3;
const FVector2* lastPoint = trianglePoint1;
for (const FVector2* collinearPoint : collinearPoints1)
{
triangles.push_back(lastPoint);
triangles.push_back(collinearPoint);
triangles.push_back(anchorPoint);
lastPoint = collinearPoint;
}
std::list<const FVector2*> emptyList;
if (point3HasCollinearVertices)
{
collinearPoints3.pop_back();
if (collinearPoints3.empty())
{
triangles.push_back(anchorPoint);
triangles.push_back(lastPoint);
triangles.push_back(trianglePoint3);
AddTriangle_R(triangles, trianglePoint2, collinearPoints2, trianglePoint3, collinearPoints3, lastPoint, emptyList);
}
else
{
triangles.push_back(lastPoint);
triangles.push_back(trianglePoint2);
triangles.push_back(anchorPoint);
AddTriangle_R(triangles, trianglePoint3, collinearPoints3, anchorPoint, emptyList, trianglePoint2, collinearPoints2);
}
}
else
{
AddTriangle_R(triangles, trianglePoint2, collinearPoints2, trianglePoint3, collinearPoints3, lastPoint, emptyList);
}
}
else if (!collinearPoints2.empty())
{
AddTriangle_R(triangles, trianglePoint2, collinearPoints2, trianglePoint3, collinearPoints3, trianglePoint1, collinearPoints1);
}
else
{
AddTriangle_R(triangles, trianglePoint3, collinearPoints3, trianglePoint1, collinearPoints1, trianglePoint2, collinearPoints2);
}
}
}
示例3: ReplaceScene
void ReplaceScene(ETransitionType transition, float time)
{
Ak_CScene* pNewScene = new Ak_CScene;
pNewScene->Create();
cocos2d::Scene *pReplaceScene = NULL;
if (NONE == transition)
{
pReplaceScene = pNewScene->GetScene();
}
else if (CROSS_FADE == transition)
{
pReplaceScene = cocos2d::TransitionCrossFade::create(time, pNewScene->GetScene());
}
else if (FADE == transition)
{
pReplaceScene = cocos2d::TransitionFade::create(time, pNewScene->GetScene());
}
else if (FADE_BL == transition)
{
pReplaceScene = cocos2d::TransitionFadeBL::create(time, pNewScene->GetScene());
}
else if (FADE_DOWN == transition)
{
}
else if (FADE_TR == transition)
{
}
else if (FADE_UP == transition)
{
}
else if (FLIP_ANGULAR == transition)
{
}
else if (FLIP_X == transition)
{
}
else if (FLIP_Y == transition)
{
}
else if (JUMP_ZOOM == transition)
{
}
else if (MOVE_IN_B == transition)
{
}
else if (MOVE_IN_L == transition)
{
}
else if (MOVE_IN_R == transition)
{
}
else if (MOVE_IN_T == transition)
{
}
else if (PAGE_TURN == transition)
{
}
else if (PROGRESS == transition)
{
}
else if (PROGRESS_HORIZONTAL == transition)
{
}
else if (PROGRESS_IN_OUT == transition)
{
}
else if (PROGRESS_OUT_IN == transition)
{
}
else if (PROGRESS_RADIAL_CCW == transition)
{
}
else if (PROGRESS_RADIAL_CW == transition)
{
}
else if (PROGRESS_VERTICAL == transition)
{
}
cocos2d::Director::getInstance()->replaceScene(pReplaceScene);
Ak_CScene* pOldScene = *(g_sceneList.rbegin());
pOldScene->Destroy();
delete pOldScene;
g_sceneList.pop_back();
g_sceneList.push_back(pNewScene);
}
示例4: move_items
// I'd love to have this not duplicate so much code from Pickup::pick_one_up(),
// but I don't see a clean way to do that.
static void move_items( player &p, const tripoint &src, bool from_vehicle,
const tripoint &dest, bool to_vehicle,
std::list<int> &indices, std::list<int> &quantities )
{
tripoint source = src + p.pos();
tripoint destination = dest + p.pos();
int s_cargo = -1;
vehicle *s_veh = nullptr;
// load vehicle information if requested
if( from_vehicle ) {
const cata::optional<vpart_reference> vp = g->m.veh_at( source ).part_with_feature( "CARGO",
false );
assert( vp );
s_veh = &vp->vehicle();
s_cargo = vp->part_index();
assert( s_cargo >= 0 );
}
while( p.moves > 0 && !indices.empty() ) {
int index = indices.back();
int quantity = quantities.back();
indices.pop_back();
quantities.pop_back();
item *temp_item = from_vehicle ? g->m.item_from( s_veh, s_cargo, index ) :
g->m.item_from( source, index );
if( temp_item == nullptr ) {
continue; // No such item.
}
item leftovers = *temp_item;
if( quantity != 0 && temp_item->count_by_charges() ) {
// Reinserting leftovers happens after item removal to avoid stacking issues.
leftovers.charges = temp_item->charges - quantity;
if( leftovers.charges > 0 ) {
temp_item->charges = quantity;
}
} else {
leftovers.charges = 0;
}
// Check that we can pick it up.
if( !temp_item->made_of_from_type( LIQUID ) ) {
// This is for hauling across zlevels, remove when going up and down stairs
// is no longer teleportation
int distance = src.z == dest.z ? std::max( rl_dist( src, dest ), 1 ) : 1;
p.mod_moves( -Pickup::cost_to_move_item( p, *temp_item ) * distance );
if( to_vehicle ) {
put_into_vehicle_or_drop( p, item_drop_reason::deliberate, { *temp_item },
destination );
} else {
drop_on_map( p, item_drop_reason::deliberate, { *temp_item }, destination );
}
// Remove from map or vehicle.
if( from_vehicle ) {
s_veh->remove_item( s_cargo, index );
} else {
g->m.i_rem( source, index );
}
}
// If we didn't pick up a whole stack, put the remainder back where it came from.
if( leftovers.charges > 0 ) {
bool to_map = !from_vehicle;
if( !to_map ) {
to_map = !s_veh->add_item( s_cargo, leftovers );
}
if( to_map ) {
g->m.add_item_or_charges( source, leftovers );
}
}
}
}
示例5: Tokenize
//.........这里部分代码省略.........
}
// maximum
if( str[1].size() > 0 ) {
max = HexToDecimal<unsigned long long>(str[1]);
} else {
max = 0;
}
// current
cur = min;
// numNibbles
numNibbles = str[1].size() > str[0].size() ? str[1].size() : str[0].size();
temp = str[2]; // we use temp later on to hold the expressions
} // else error
numNibbles %= 16+1; // can't have more than 16 nibbles
if( min > max ) // if start is greater than stop
{
std::swap(min,max);
}
// if cur is out of range
if( !(cur >= min && cur <= max) ) {
cur = min;
}
currentPkt = DecimalToHexL(cur);
currentPkt = currentPkt.Mid(0,numNibbles);
wxString val = _("");
PartialPacketToken pktToken;
for( size_t i=0, j=0; i < temp.size(); ++i )
{
bool foundToken = true;
switch( static_cast<char>(temp[i]))
{
case '+':
pktToken.type = PARTIAL_PACKET_ADDITION;
pktToken.value = _("+");
break;
case '-':
pktToken.type = PARTIAL_PACKET_SUBTRACTION;
pktToken.value = _("-");
break;
case '*':
pktToken.type = PARTIAL_PACKET_MULTIPLICATION;
pktToken.value = _("*");
break;
case '/':
pktToken.type = PARTIAL_PACKET_DIVISION;
pktToken.value = _("/");
break;
case 'P': // case p should always follow this
case 'p':
pktToken.type = PARTIAL_PACKET_PACKET;
pktToken.value = _("p");
break;
default:
foundToken = false;
}
// add token with a value
if( !foundToken )
{
val += temp[i];
}
else
{
if( val.size() > 0 ) // append the partial packet value before the other token
{
if( tokens.size() == 0 ) // if there was no expression token before this value, then default to addition
tokens.push_back( PartialPacketToken(PARTIAL_PACKET_ADDITION, _("+")) );
tokens.push_back( PartialPacketToken(PARTIAL_PACKET_VALUE, val) );
val.Clear();
}
if( tokens.back().type == PARTIAL_PACKET_ADDITION ||
tokens.back().type == PARTIAL_PACKET_SUBTRACTION ||
tokens.back().type == PARTIAL_PACKET_MULTIPLICATION ||
tokens.back().type == PARTIAL_PACKET_DIVISION )
{
tokens.back() = pktToken; // only store last symbol
}
else
tokens.push_back(pktToken);
}
}
if( val.size() > 0 )
{
if( tokens.size() == 0 ) // if there was no expression token before this value, then default to addition
tokens.push_back( PartialPacketToken(PARTIAL_PACKET_ADDITION, _("+")) );
tokens.push_back( PartialPacketToken(PARTIAL_PACKET_VALUE, val) );
}
else if(
tokens.size() > 0 &&
(tokens.back().type == PARTIAL_PACKET_ADDITION ||
tokens.back().type == PARTIAL_PACKET_SUBTRACTION ||
tokens.back().type == PARTIAL_PACKET_MULTIPLICATION ||
tokens.back().type == PARTIAL_PACKET_DIVISION) )
{
tokens.pop_back(); // can't end with a symbol
}
}
示例6:
CContext::~CContext()
{
g_backtrace.pop_back();
}
示例7: move_items
// I'd love to have this not duplicate so much code from Pickup::pick_one_up(),
// but I don't see a clean way to do that.
static void move_items( const tripoint &src, bool from_vehicle,
const tripoint &dest, bool to_vehicle,
std::list<int> &indices, std::list<int> &quantities )
{
tripoint source = src + g->u.pos();
tripoint destination = dest + g->u.pos();
int s_cargo, d_cargo; // oui oui, mon frere
s_cargo = d_cargo = -1;
vehicle *s_veh, *d_veh; // 2diva4me
s_veh = d_veh = nullptr;
// load vehicle information if requested
if( from_vehicle ) {
const cata::optional<vpart_reference> vp = g->m.veh_at( source ).part_with_feature( "CARGO",
false );
assert( vp );
s_veh = &vp->vehicle();
s_cargo = vp->part_index();
assert( s_cargo >= 0 );
}
if( to_vehicle ) {
const cata::optional<vpart_reference> vp = g->m.veh_at( destination ).part_with_feature( "CARGO",
false );
assert( vp );
d_veh = &vp->vehicle();
d_cargo = vp->part_index();
assert( d_cargo >= 0 );
}
while( g->u.moves > 0 && !indices.empty() ) {
int index = indices.back();
int quantity = quantities.back();
indices.pop_back();
quantities.pop_back();
item *temp_item = from_vehicle ? g->m.item_from( s_veh, s_cargo, index ) : g->m.item_from( source,
index );
if( temp_item == nullptr ) {
continue; // No such item.
}
item leftovers = *temp_item;
if( quantity != 0 && temp_item->count_by_charges() ) {
// Reinserting leftovers happens after item removal to avoid stacking issues.
leftovers.charges = temp_item->charges - quantity;
if( leftovers.charges > 0 ) {
temp_item->charges = quantity;
}
} else {
leftovers.charges = 0;
}
// Check that we can pick it up.
if( !temp_item->made_of( LIQUID ) ) {
g->u.mod_moves( -Pickup::cost_to_move_item( g->u, *temp_item ) );
if( to_vehicle ) {
put_into_vehicle_or_drop( g->u, { *temp_item }, destination );
} else {
drop_on_map( g->u, { *temp_item }, destination );
}
// Remove from map or vehicle.
if( from_vehicle ) {
s_veh->remove_item( s_cargo, index );
} else {
g->m.i_rem( source, index );
}
}
// If we didn't pick up a whole stack, put the remainder back where it came from.
if( leftovers.charges > 0 ) {
bool to_map = !from_vehicle;
if( !to_map ) {
to_map = !s_veh->add_item( s_cargo, leftovers );
}
if( to_map ) {
g->m.add_item_or_charges( source, leftovers );
}
}
}
}
示例8: good_pop_back_list1
void good_pop_back_list1(std::list<int> &L, int n) {
auto i0 = L.cbegin(), i1 = L.cend(), i2 = i1--;
L.pop_back();
*i0; // no-warning
*i2; // no-warning
}
示例9: bad_pop_back_list1
void bad_pop_back_list1(std::list<int> &L, int n) {
auto i0 = L.cbegin(), i1 = L.cend(), i2 = i1--;
L.pop_back();
*i1; // expected-warning{{Invalidated iterator accessed}}
}
示例10: render_screen
void render_screen(int fd, std::string str)
{
// Clear the screen
memset(frontstore, 0, sizeof(frontstore));
auto render_string = [](std::string str, int start_line)
{
// The start line, and start x coordinate
int line = start_line;
int char_x = 1;
// Run the entire string, char by char
for(char& c : str)
{
// Find the pixel letter corresponding to the char
Letter l = find_letter(c);
// If we overflow this line, by adding it, do a line break
if(char_x + l.letter_width >= YSIZE)
{
char_x = 1;
line++;
// If we overflow the screen, skip the rest of the string
if(line > 2)
{
break;
}
}
// Calculate our y coord, based upon the line, we're in
int char_y = 0 + line * (LETTER_HEIGHT + 1);
// Do the actual printing of the character
put_letter(char_y, char_x, l);
// Move the size of this letter, and 1 character,
// before rendering the next character
char_x += l.letter_width;
char_x += 1;
}
// People who start on the line after us
return line+1;
};
// Write the new string
int end_line = render_string(str, 0);
// If the new string did not take up all the space,
// lets reload some of the old stuff, and draw that
for(std::string old : old_lines)
{
// Only draw, if we're inside the screen
if(end_line > 2)
{
break;
}
end_line = render_string(old, end_line);
}
// The string we just rendered, is now an old line
old_lines.push_front(str);
// Garbage collect old_lines
while(old_lines.size() > 3)
{
old_lines.pop_back();
}
// Render!
scr_frontmap(fd);
}
示例11: pop
T pop() {
SpinLock::LockGuard l(lock_);
T msg = messages_.back();
messages_.pop_back();
return msg;
}
示例12: parse_commandline_options
//.........这里部分代码省略.........
MyValueArg<string> allowed_build_opt("", "build", "Selects only a build with the given name.", false, "", "build name");
args.push_back(&allowed_build_opt);
myOutput.setArgCategory(allowed_build_opt, INPUT_CTRL);
MyMultiArg<string> allowed_banks_opt("", "bank", "Selects only animations in the given banks.", false, "bank name");
args.push_back(&allowed_banks_opt);
myOutput.setArgCategory(allowed_banks_opt, INPUT_CTRL);
SwitchArg mark_atlas_opt("", "mark-atlases", "Instead of performing any conversion, saves the atlases in the specified build as PNG, with their clipped regions shaded grey.");
args.push_back(&mark_atlas_opt);
myOutput.setArgCategory(mark_atlas_opt, OUTPUT_CTRL);
MyValueArg<string> build_rename_opt("", "rename-build", "Renames the input build to the given name.", false, "", "build name");
args.push_back(&build_rename_opt);
//myOutput.setArgCategory(build_rename_opt, TO_SCML);
MyValueArg<string> banks_rename_opt("", "rename-bank", "Renames the input banks to the given name.", false, "", "bank name");
args.push_back(&banks_rename_opt);
//myOutput.setArgCategory(banks_rename_opt, TO_SCML);
SwitchArg check_anim_fidelity_opt("", "check-animation-fidelity", "Checks if the Spriter representation of the animations is faithful to the source animations.");
args.push_back(&check_anim_fidelity_opt);
myOutput.setArgCategory(check_anim_fidelity_opt, TO_SCML);
MultiSwitchArg verbosity_flag("v", "verbose", "Increases output verbosity.");
args.push_back(&verbosity_flag);
SwitchArg quiet_flag("q", "quiet", "Disables text output. Overrides the verbosity value.");
args.push_back(&quiet_flag);
MultiArgumentOption multiinput_opt("INPUT-PATH", "Input path.", true, "INPUT-PATH");
cmd.add(multiinput_opt);
/*
* This only marks the option visually, since all paths are globbed by multiinput_opt.
*/
ArgumentOption dummy_output_opt("OUTPUT-PATH", "Output path.", false, "OUTPUT-DIR");
dummy_output_opt.setVisuallyRequired(true);
cmd.add(dummy_output_opt);
for(list<Arg*>::reverse_iterator it = args.rbegin(); it != args.rend(); ++it) {
cmd.add(*it);
}
cmd.parse(argc, argv);
if(allowed_build_opt.isSet()) {
options::allowed_build = Just(allowed_build_opt.getValue());
}
if(allowed_banks_opt.isSet()) {
const vector<string>& banks = allowed_banks_opt.getValue();
options::allowed_banks.insert(options::allowed_banks.begin(), banks.begin(), banks.end());
}
options::mark_atlas = mark_atlas_opt.getValue();
if(build_rename_opt.isSet()) {
options::build_rename = Just(build_rename_opt.getValue());
}
if(banks_rename_opt.isSet()) {
options::banks_rename = Just(banks_rename_opt.getValue());
}
options::check_animation_fidelity = check_anim_fidelity_opt.getValue();
if(quiet_flag.getValue()) {
options::verbosity = -1;
}
else {
options::verbosity = verbosity_flag.getValue();
}
/*
options::info = info_flag.getValue();
*/
const std::vector<std::string>& all_paths = multiinput_opt.getValue();
if(all_paths.size() < 2) {
dummy_output_opt.forceRequired();
cmd.parse(argc, argv);
// This should never be throws, because the above cmd.parse() is meant
// to raise an error and exit the program.
throw KToolsError("Missing output-path argument.");
}
std::copy(all_paths.begin(), all_paths.end(), std::back_inserter(input_paths));
output_path = input_paths.back();
input_paths.pop_back();
} catch (ArgException& e) {
cerr << "error: " << e.error() << " for arg " << e.argId() << endl;
exit(1);
} catch(exception& e) {
cerr << "error: " << e.what() << endl;
exit(1);
}
}
示例13: extract_peers_from_bootstrap_nodes_dat
void extract_peers_from_bootstrap_nodes_dat(const unsigned char *buffer, std::list<Contact *>& bootstrap_list)
{
/*
The header is so composed:
uint32_t reserved0 set to zero
uint32_t reserved1 set to 0x00000003
uint32_t bootstrap_edition nodes.dat bootstrap version
uint32_t num_entries number of entries in the file
*/
if(!bootstrap_list.empty())
return;
uint32_t reserved0 = *(uint32_t *)&(buffer[0]);
uint32_t reserved1 = *(uint32_t *)&(buffer[4]);
uint32_t num_entries = *(uint32_t *)&(buffer[12]);
if(reserved0 != 0 || reserved1 != 3)
// wow: this bootstrap nodes.dat is invalid
return;
unsigned char *peer = (unsigned char *)&(buffer[16]);
/*
The peer is so composed:
uint64_t low_peer_id 128-bit peer identifier (MD4 of node ID)
uint64_t high_peer_id
uint32_t peer_ip IP address of the peer
uint16_t udp_port peer UDP port number
uint16_t tcp_port peer TCP port number
unsigned char version peer contact version
*/
for(unsigned int i = 0; i < num_entries; i++, peer += 25)
{
uint32_t peer_ip = ntohl(*(uint32_t *)&(peer[16]));
uint16_t udp_port = *(uint16_t *)&(peer[20]);
uint16_t tcp_port = *(uint16_t *)&(peer[22]);
unsigned char version = peer[24];
if(version > 7)
{
// Only the 50 closest nodes, please
uint128_t distance(Kad::get_instance().get_client_id());
uint128_t peer_id = uint128_t::get_from_buffer(peer);
distance ^= peer_id;
if(bootstrap_list.size() < 50 || bootstrap_list.back()->get_distance() > distance)
{
Contact *new_peer = new Contact(uint128_t::get_from_buffer(peer),
peer_ip,
udp_port,
tcp_port,
version,
0,
false);
bool peer_added = false;
for(std::list<Contact *>::iterator peerIt = bootstrap_list.begin();
peerIt != bootstrap_list.end();
peerIt++)
{
if((*peerIt)->get_distance() > distance)
{
bootstrap_list.insert(peerIt, new_peer);
peer_added = true;
break;
}
}
if(!peer_added)
{
bootstrap_list.push_back(new_peer);
}
else if(bootstrap_list.size() > 50)
{
delete bootstrap_list.back();
bootstrap_list.pop_back();
}
}
}
}
}
示例14: hexchat_plugin_deinit
int hexchat_plugin_deinit(hexchat_plugin *plugin_handle)
{
/******************************************/
/****** Remove the Icon from the tray *****/
/******************************************/
StopBlink(g_hXchatWnd, 1, g_hIcons[0]);
RemoveIcon(g_hXchatWnd, 1);
/*******************************************/
/*******************************************/
/*******************************************/
if(g_dwPrefs & (1<<PREF_DNSIT))
{
DWORD dwStyle;
dwStyle = GetWindowLong(g_hXchatWnd, GWL_STYLE);
dwStyle &= ~(1<<WS_CHILD);
SetWindowLongPtr(g_hXchatWnd, GWL_STYLE, (LONG_PTR)dwStyle);
SetWindowLongPtr(g_hXchatWnd, GWL_HWNDPARENT, NULL);
}
/******************************************/
/****** Unload our resources **************/
/******************************************/
DestroyMenu(g_hTrayMenu);
for(int i = 0; i <= 11; i++)
{
DestroyIcon(g_hIcons[i]);
}
/******************************************/
/****** Remove our window hook ************/
/******************************************/
SetWindowLongPtr(g_hXchatWnd, GWLP_WNDPROC, (LONG_PTR)g_hOldProc);
/******************************************/
/****** Remove our hotkey, and destroy ****/
/****** the window that receives its ****/
/****** messages ****/
/******************************************/
UnregisterHotKey(g_hHotkeyWnd, 1);
DestroyWindow(g_hHotkeyWnd);
DestroyWindow(g_hPrefDlg);
/******************************************/
/************* Clean up Isle 7 ************/
/******************************************/
if(sdAlertNum())
{
sdCloseAlerts();
}
/******************************************/
/****** remove our hexchat_hook_*s **********/
/******************************************/
while(!g_vHooks.empty())
{
if(g_vHooks.back() != NULL)
{
hexchat_unhook(ph, g_vHooks.back());
}
g_vHooks.pop_back();
}
return 1;
}
示例15: Trace
//.........这里部分代码省略.........
// normal raytracing
if(PHOTONMAP_GLOBAL_BIT(depth, depth2) && !isPerfectReflection && this->globalMap)
{
std::vector<Photon*> photons;
globalMap->FindInRange(position, this->globalPhotonMapGatherRadius, photons);
// We estimate radiance at the point.
Vec3 Flux(0,0,0);
for(std::vector<Photon*>::iterator i = photons.begin(); i != photons.end(); i++)
{
Photon* p = *i;
// Cull backfacings.
if(p->outDirection * result.normal < 0)
continue;
Flux += p->power.CMultiply((result.normal * p->outDirection) * result.material->bsdf->BSDF(position, result.normal, p->outDirection, cameraDirection, result.materialData,
insideMedium, outsideMedium));
}
Vec3 t = Flux / (PI*this->globalPhotonMapGatherRadius*this->globalPhotonMapGatherRadius);
L += PHOTONMAP_GLOBAL_MASK(depth, depth2, t);
// We skip through
return scateringWeight.CMultiply(L);
}
// 4b) integrated radiance over hemisphere
if((samplingType & MultipleSample) == 0 || INDIRECT_LIGHTNING_BIT(depth, depth2) == false)
return scateringWeight.CMultiply(L);
if(depth2 < this->maxGatherIterations || isPerfectReflection)
{
// If perfect reflection, we need only one ray to approximate.
for(int i = 0; i < numberOfSamples; i++)
{
Vec3 newDirection;
ColourScalar S = result.material->bsdf->Sample(i, numberOfSamples, position, result.normal,
cameraDirection, random, result.materialData, insideMedium, outsideMedium, newDirection);
// Trace new ray.
Ray newRay(position, newDirection);
bool needsPop = false, needsPush = false;
Scalar translateInwards = -1;
if(isInsideMedium)
{
// In-Out combination
if(newDirection * result.normal > 0)
{
newRay.medium = mediumList.back();
mediumList.pop_back();
needsPush = true;
translateInwards = 1;
}
// In-In combination
else
newRay.medium = ray.medium;
}
else {
// Out-out combination
if(newDirection * result.normal > 0)
newRay.medium = ray.medium;
else
{
newRay.medium = result.material->insideMedium;
mediumList.push_back(ray.medium);
needsPop = true;
translateInwards = 1;
}
}
// Translation of ray position so the whole solid angle can be sampled (also in corners)
newRay.origin = newRay.origin + (translateInwards * this->hitTranslate) * ray.direction;
ColourScalar newL = Trace(newRay, random, depth+1, depth2 + (isPerfectReflection ? 0 : 1), mediumList);
// Undo medium list to prev state
if(needsPush)
mediumList.push_back(newRay.medium);
if(needsPop)
mediumList.pop_back();
// NaN check (FIXME: must get rid of it and find the source).
if(newL.x != newL.x || newL.y != newL.y || newL.z != newL.z)
{
continue;
}
// Add already weighted result to intensity.
Vec3 t = S.CMultiply(newL);
L += INDIRECT_LIGHTNING_MASK(depth,depth2,t);
}
}
return scateringWeight.CMultiply(L);
}