本文整理汇总了C++中ERR_FAIL函数的典型用法代码示例。如果您正苦于以下问题:C++ ERR_FAIL函数的具体用法?C++ ERR_FAIL怎么用?C++ ERR_FAIL使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ERR_FAIL函数的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: ERR_FAIL_INDEX
void FixedMaterial::set_parameter(Parameter p_parameter, const Variant& p_value) {
ERR_FAIL_INDEX(p_parameter,PARAM_MAX);
if ((p_parameter==PARAM_DIFFUSE || p_parameter==PARAM_SPECULAR || p_parameter==PARAM_EMISSION)) {
if (p_value.get_type()!=Variant::COLOR) {
ERR_EXPLAIN(String(_param_names[p_parameter])+" expects Color");
ERR_FAIL();
}
} else {
if (!p_value.is_num()) {
ERR_EXPLAIN(String(_param_names[p_parameter])+" expects scalar");
ERR_FAIL();
}
}
ERR_FAIL_COND( (p_parameter==PARAM_DIFFUSE || p_parameter==PARAM_SPECULAR || p_parameter==PARAM_EMISSION) && p_value.get_type()!=Variant::COLOR );
ERR_FAIL_COND( p_parameter!=PARAM_SHADE_PARAM && p_parameter!=PARAM_DIFFUSE && p_parameter!=PARAM_DETAIL && p_parameter!=PARAM_SPECULAR && p_parameter!=PARAM_EMISSION && p_value.get_type()!=Variant::REAL && p_value.get_type()!=Variant::INT );
param[p_parameter]=p_value;
VisualServer::get_singleton()->fixed_material_set_param(material,(VS::FixedMaterialParam)p_parameter,p_value);
_change_notify(_full_param_names[p_parameter]);
}
开发者ID:Ace17,项目名称:godot,代码行数:26,代码来源:material.cpp
示例2: ERR_FAIL_COND
void Sample::_set_data(const Dictionary& p_data) {
ERR_FAIL_COND(!p_data.has("packing"));
String packing = p_data["packing"];
if (packing=="raw") {
ERR_FAIL_COND( !p_data.has("stereo"));
ERR_FAIL_COND( !p_data.has("format"));
ERR_FAIL_COND( !p_data.has("length"));
bool stereo=p_data["stereo"];
int length=p_data["length"];
Format fmt;
String fmtstr=p_data["format"];
if (fmtstr=="pcm8")
fmt=FORMAT_PCM8;
else if (fmtstr=="pcm16")
fmt=FORMAT_PCM16;
else if (fmtstr=="ima_adpcm")
fmt=FORMAT_IMA_ADPCM;
else {
ERR_EXPLAIN("Invalid format for sample: "+fmtstr);
ERR_FAIL();
}
ERR_FAIL_COND(!p_data.has("data"));
create(fmt,stereo,length);
set_data(p_data["data"]);
} else {
ERR_EXPLAIN("Invalid packing for sample data: "+packing);
ERR_FAIL();
}
}
开发者ID:03050903,项目名称:godot,代码行数:35,代码来源:sample.cpp
示例3: switch
void ConnectDialog::_add_bind() {
if (cdbinds->params.size() >= VARIANT_ARG_MAX)
return;
Variant::Type vt = (Variant::Type)type_list->get_item_ID(type_list->get_selected());
Variant value;
switch(vt) {
case Variant::BOOL: value = false ; break;
case Variant::INT: value = 0; break;
case Variant::REAL: value = 0.0; break;
case Variant::STRING: value = ""; break;
case Variant::VECTOR2: value = Vector2(); break;
case Variant::RECT2: value = Rect2(); break;
case Variant::VECTOR3: value = Vector3(); break;
case Variant::PLANE: value = Plane(); break;
case Variant::QUAT: value = Quat(); break;
case Variant::_AABB: value = AABB(); break;
case Variant::MATRIX3: value = Matrix3(); break;
case Variant::TRANSFORM: value = Transform(); break;
case Variant::COLOR: value = Color(); break;
case Variant::IMAGE: value = Image(); break;
default: { ERR_FAIL(); } break;
}
ERR_FAIL_COND(value.get_type()==Variant::NIL);
cdbinds->params.push_back(value);
cdbinds->notify_changed();
}
开发者ID:Ranmus,项目名称:godot,代码行数:34,代码来源:connections_dialog.cpp
示例4: print_unhandled_exception
void print_unhandled_exception(MonoObject *p_exc, bool p_recursion_caution) {
mono_print_unhandled_exception(p_exc);
#ifdef DEBUG_ENABLED
if (!ScriptDebugger::get_singleton())
return;
ScriptLanguage::StackInfo separator;
separator.file = "";
separator.func = "--- " + RTR("End of inner exception stack trace") + " ---";
separator.line = 0;
Vector<ScriptLanguage::StackInfo> si;
String exc_msg = "";
while (p_exc != NULL) {
GDMonoClass *st_klass = CACHED_CLASS(System_Diagnostics_StackTrace);
MonoObject *stack_trace = mono_object_new(mono_domain_get(), st_klass->get_mono_ptr());
MonoBoolean need_file_info = true;
void *ctor_args[2] = { p_exc, &need_file_info };
MonoObject *unexpected_exc = NULL;
CACHED_METHOD(System_Diagnostics_StackTrace, ctor_Exception_bool)->invoke_raw(stack_trace, ctor_args, &unexpected_exc);
if (unexpected_exc != NULL) {
mono_print_unhandled_exception(unexpected_exc);
if (p_recursion_caution) {
// Called from CSharpLanguage::get_current_stack_info,
// so printing an error here could result in endless recursion
OS::get_singleton()->printerr("Mono: Method GDMonoUtils::print_unhandled_exception failed");
return;
} else {
ERR_FAIL();
}
}
Vector<ScriptLanguage::StackInfo> _si;
if (stack_trace != NULL && !p_recursion_caution) {
_si = CSharpLanguage::get_singleton()->stack_trace_get_info(stack_trace);
for (int i = _si.size() - 1; i >= 0; i--)
si.insert(0, _si[i]);
}
exc_msg += (exc_msg.length() > 0 ? " ---> " : "") + GDMonoUtils::get_exception_name_and_message(p_exc);
GDMonoProperty *p_prop = GDMono::get_singleton()->get_class(mono_object_get_class(p_exc))->get_property("InnerException");
p_exc = p_prop != NULL ? p_prop->get_value(p_exc) : NULL;
if (p_exc != NULL)
si.insert(0, separator);
}
String file = si.size() ? si[0].file : __FILE__;
String func = si.size() ? si[0].func : FUNCTION_STR;
int line = si.size() ? si[0].line : __LINE__;
String error_msg = "Unhandled exception";
ScriptDebugger::get_singleton()->send_error(func, file, line, error_msg, exc_msg, ERR_HANDLER_ERROR, si);
#endif
}
开发者ID:Ranakhamis,项目名称:godot,代码行数:60,代码来源:gd_mono_utils.cpp
示例5: get_global_transform
void Spatial::look_at(const Vector3 &p_target, const Vector3 &p_up_normal) {
Transform lookat;
lookat.origin = get_global_transform().origin;
if (lookat.origin == p_target) {
ERR_EXPLAIN("Node origin and target are in the same position, look_at() failed");
ERR_FAIL();
}
if (p_up_normal.cross(p_target - lookat.origin) == Vector3()) {
ERR_EXPLAIN("Up vector and direction between node origin and target are aligned, look_at() failed");
ERR_FAIL();
}
lookat = lookat.looking_at(p_target, p_up_normal);
set_global_transform(lookat);
}
开发者ID:allkhor,项目名称:godot,代码行数:16,代码来源:spatial.cpp
示例6: _parse_hex
static void _parse_hex(const String& p_string, int p_start, uint8_t* p_dst) {
uint16_t ret = 0;
for (int i=p_start; i<p_start + 4; i++) {
if (i >= p_string.length()) {
break;
};
int n = 0;
CharType c = p_string[i];
if (c >= '0' && c <= '9') {
n = c - '0';
} else if (c >= 'a' && c <= 'f') {
n = 10 + (c - 'a');
} else if (c >= 'A' && c <= 'F') {
n = 10 + (c - 'A');
} else if (c == ':') {
break;
} else {
ERR_EXPLAIN("Invalid character in ipv6 address: " + p_string);
ERR_FAIL();
};
ret = ret << 4;
ret += n;
};
p_dst[0] = ret >> 8;
p_dst[1] = ret & 0xff;
};
开发者ID:FEDE0D,项目名称:godot,代码行数:31,代码来源:ip_address.cpp
示例7: ERR_FAIL_NULL
void Object::disconnect(const StringName& p_signal, Object *p_to_object, const StringName& p_to_method) {
ERR_FAIL_NULL(p_to_object);
Signal *s = signal_map.getptr(p_signal);
if (!s) {
ERR_EXPLAIN("Nonexistent signal: "+p_signal);
ERR_FAIL_COND(!s);
}
if (s->lock>0) {
ERR_EXPLAIN("Attempt to disconnect signal '"+p_signal+"' while emitting (locks: "+itos(s->lock)+")");
ERR_FAIL_COND(s->lock>0);
}
Signal::Target target(p_to_object->get_instance_ID(),p_to_method);
if (!s->slot_map.has(target)) {
ERR_EXPLAIN("Disconnecting nonexistent signal '"+p_signal+"', slot: "+itos(target._id)+":"+target.method);
ERR_FAIL();
}
p_to_object->connections.erase(s->slot_map[target].cE);
s->slot_map.erase(target);
if (s->slot_map.empty() && ObjectTypeDB::has_signal(get_type_name(),p_signal )) {
//not user signal, delete
signal_map.erase(p_signal);
}
}
开发者ID:Brickcaster,项目名称:godot,代码行数:28,代码来源:object.cpp
示例8: GET_SCRIPT_DESC
void NativeScriptInstance::get_property_list(List<PropertyInfo> *p_properties) const {
script->get_script_property_list(p_properties);
NativeScriptDesc *script_data = GET_SCRIPT_DESC();
while (script_data) {
Map<StringName, NativeScriptDesc::Method>::Element *E = script_data->methods.find("_get_property_list");
if (E) {
godot_variant result;
result = E->get().method.method((godot_object *)owner,
E->get().method.method_data,
userdata,
0,
NULL);
Variant res = *(Variant *)&result;
godot_variant_destroy(&result);
if (res.get_type() != Variant::ARRAY) {
ERR_EXPLAIN("_get_property_list must return an array of dictionaries");
ERR_FAIL();
}
Array arr = res;
for (int i = 0; i < arr.size(); i++) {
Dictionary d = arr[i];
ERR_CONTINUE(!d.has("name"));
ERR_CONTINUE(!d.has("type"));
PropertyInfo info;
info.type = Variant::Type(d["type"].operator int64_t());
ERR_CONTINUE(info.type < 0 || info.type >= Variant::VARIANT_MAX);
info.name = d["name"];
ERR_CONTINUE(info.name == "");
if (d.has("hint")) {
info.hint = PropertyHint(d["hint"].operator int64_t());
}
if (d.has("hint_string")) {
info.hint_string = d["hint_string"];
}
if (d.has("usage")) {
info.usage = d["usage"];
}
p_properties->push_back(info);
}
}
script_data = script_data->base_data;
}
return;
}
开发者ID:KelinciFX,项目名称:godot,代码行数:59,代码来源:nativescript.cpp
示例9: ERR_EXPLAIN
void Object::call_multilevel(const StringName& p_name, VARIANT_ARG_DECLARE) {
#if 0
if (p_name==CoreStringNames::get_singleton()->_free) {
#ifdef DEBUG_ENABLED
if (cast_to<Reference>()) {
ERR_EXPLAIN("Can't 'free' a reference.");
ERR_FAIL();
return;
}
#endif
//must be here, must be before everything,
memdelete(this);
return;
}
VARIANT_ARGPTRS;
int argc=0;
for(int i=0;i<VARIANT_ARG_MAX;i++) {
if (argptr[i]->get_type()==Variant::NIL)
break;
argc++;
}
Variant::CallError error;
if (script_instance) {
script_instance->call(p_name,argptr,argc,error);
_test_call_error(p_name,error);
}
MethodBind *method=ObjectTypeDB::get_method(get_type_name(),p_name);
if (method) {
method->call(this,argptr,argc,error);
_test_call_error(p_name,error);
}
#else
VARIANT_ARGPTRS;
int argc=0;
for(int i=0;i<VARIANT_ARG_MAX;i++) {
if (argptr[i]->get_type()==Variant::NIL)
break;
argc++;
}
//Variant::CallError error;
call_multilevel(p_name,argptr,argc);
#endif
}
开发者ID:Brickcaster,项目名称:godot,代码行数:58,代码来源:object.cpp
示例10: ERR_EXPLAIN
void CanvasItem::draw_line(const Point2& p_from, const Point2& p_to,const Color& p_color,float p_width) {
if (!drawing) {
ERR_EXPLAIN("Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal.");
ERR_FAIL();
}
VisualServer::get_singleton()->canvas_item_add_line(canvas_item,p_from,p_to,p_color,p_width);
}
开发者ID:AMG194,项目名称:godot,代码行数:9,代码来源:canvas_item.cpp
示例11: ERR_EXPLAIN
void CanvasItem::draw_set_transform_matrix(const Transform2D &p_matrix) {
if (!drawing) {
ERR_EXPLAIN("Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal.");
ERR_FAIL();
}
VisualServer::get_singleton()->canvas_item_add_set_transform(canvas_item, p_matrix);
}
开发者ID:brakhane,项目名称:godot,代码行数:9,代码来源:canvas_item.cpp
示例12: ERR_FAIL_COND
void CPSampleManagerImpl::get_chunk(CPSample_ID p_id,int32_t p_index,void *p_data,int p_data_len) {
SampleData *sd=_getsd(p_id);
#ifdef DEBUG_ENABLED
ERR_FAIL_COND(!valid.has(sd));
#endif
ERR_FAIL();
}
开发者ID:AMG194,项目名称:godot,代码行数:9,代码来源:event_stream_chibi.cpp
示例13: ERR_EXPLAIN
void AudioDriverXAudio2::start() {
active = true;
HRESULT hr = source_voice->Start(0);
if (hr != S_OK) {
ERR_EXPLAIN("XAudio2 start error " + itos(hr));
ERR_FAIL();
}
};
开发者ID:rrrfffrrr,项目名称:godot,代码行数:9,代码来源:audio_driver_xaudio2.cpp
示例14: get_script_instance
void EditorImportPlugin::import_dialog(const String& p_from) {
if (get_script_instance() && get_script_instance()->has_method("import_dialog")) {
get_script_instance()->call("import_dialog",p_from);
return;
}
ERR_FAIL();
}
开发者ID:BigJoe02,项目名称:godot,代码行数:10,代码来源:editor_import_export.cpp
示例15: switch
void GodotSharpEditor::_menu_option_pressed(int p_id) {
switch (p_id) {
case MENU_CREATE_SLN: {
_create_project_solution();
} break;
default:
ERR_FAIL();
}
}
开发者ID:KelinciFX,项目名称:godot,代码行数:11,代码来源:godotsharp_editor.cpp
示例16: godot_pluginscript_register_language
void GDAPI godot_pluginscript_register_language(const godot_pluginscript_language_desc *language_desc) {
Error ret = _check_language_desc(language_desc);
if (ret) {
ERR_FAIL();
}
PluginScriptLanguage *language = memnew(PluginScriptLanguage(language_desc));
ScriptServer::register_language(language);
ResourceLoader::add_resource_format_loader(language->get_resource_loader());
ResourceSaver::add_resource_format_saver(language->get_resource_saver());
pluginscript_languages.push_back(language);
}
开发者ID:93i,项目名称:godot,代码行数:11,代码来源:register_types.cpp
示例17: while
void IP_Unix::get_local_addresses(List<IP_Address> *r_addresses) const {
ULONG buf_size = 1024;
IP_ADAPTER_ADDRESSES* addrs;
while (true) {
addrs = (IP_ADAPTER_ADDRESSES*)memalloc(buf_size);
int err = GetAdaptersAddresses(AF_INET, GAA_FLAG_SKIP_ANYCAST |
GAA_FLAG_SKIP_MULTICAST |
GAA_FLAG_SKIP_DNS_SERVER |
GAA_FLAG_SKIP_FRIENDLY_NAME,
NULL, addrs, &buf_size);
if (err == NO_ERROR) {
break;
};
memfree(addrs);
if (err == ERROR_BUFFER_OVERFLOW) {
continue; // will go back and alloc the right size
};
ERR_EXPLAIN("Call to GetAdaptersAddresses failed with error " + itos(err));
ERR_FAIL();
return;
};
IP_ADAPTER_ADDRESSES* adapter = addrs;
while (adapter != NULL) {
IP_ADAPTER_UNICAST_ADDRESS* address = adapter->FirstUnicastAddress;
while (address != NULL) {
char addr_chr[INET_ADDRSTRLEN];
SOCKADDR_IN* ipv4 = reinterpret_cast<SOCKADDR_IN*>(address->Address.lpSockaddr);
IP_Address ip;
ip.host= *((unsigned long*)&ipv4->sin_addr);
//inet_ntop(AF_INET, &ipv4->sin_addr, addr_chr, INET_ADDRSTRLEN);
r_addresses->push_back(ip);
address = address->Next;
};
adapter = adapter->Next;
};
memfree(addrs);
};
开发者ID:03050903,项目名称:godot,代码行数:52,代码来源:ip_unix.cpp
示例18: ERR_EXPLAIN
void EMWSPeer::read_msg(uint8_t *p_data, uint32_t p_size, bool p_is_string) {
if (in_buffer.space_left() < p_size + 5) {
ERR_EXPLAIN("Buffer full! Dropping data");
ERR_FAIL();
}
uint8_t is_string = p_is_string ? 1 : 0;
in_buffer.write((uint8_t *)&p_size, 4);
in_buffer.write((uint8_t *)&is_string, 1);
in_buffer.write(p_data, p_size);
queue_count++;
}
开发者ID:Ranakhamis,项目名称:godot,代码行数:13,代码来源:emws_peer.cpp
注:本文中的ERR_FAIL函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论