mirror of
https://codeberg.org/fairyglade/ly.git
synced 2026-08-09 15:19:13 +02:00
no panic
This commit is contained in:
parent
396df52ced
commit
1be98f2163
1 changed files with 7 additions and 19 deletions
|
|
@ -165,23 +165,16 @@ pub fn configFieldHandler(_: std.mem.Allocator, field: ini.IniField) ?ini.IniFie
|
|||
|
||||
if (std.mem.startsWith(u8, field.header, "cmd:")) {
|
||||
const key = field.header[4..];
|
||||
const keyZ = temporary_allocator.dupe(u8, key) catch |e|
|
||||
std.debug.panic("CustomCommands.binds: {} while duping key {s}", .{e, key});
|
||||
const keyZ = temporary_allocator.dupe(u8, key) catch "";
|
||||
if (!CustomCommands.binds.contains(key)) {
|
||||
CustomCommands.binds.put(keyZ, .{}) catch |e| {
|
||||
std.debug.panic("CustomCommands.binds: {} while putting for key {s}", .{e, key});
|
||||
};
|
||||
CustomCommands.binds.put(keyZ, .{}) catch {};
|
||||
}
|
||||
if (CustomCommands.binds.getPtr(keyZ)) |command| {
|
||||
if (std.mem.eql(u8, field.key, "name")) {
|
||||
command.name = temporary_allocator.dupe(u8, field.value) catch |e| {
|
||||
std.debug.panic("CustomCommands.binds: {} while duping name '{s}'", .{e, field.value});
|
||||
};
|
||||
command.name = temporary_allocator.dupe(u8, field.value) catch "";
|
||||
}
|
||||
if (std.mem.eql(u8, field.key, "cmd")) {
|
||||
command.cmd = temporary_allocator.dupe(u8, field.value) catch |e| {
|
||||
std.debug.panic("CustomCommands.binds: {} while duping command '{s}", .{e, field.value});
|
||||
};
|
||||
command.cmd = temporary_allocator.dupe(u8, field.value) catch "";
|
||||
}
|
||||
if (std.mem.eql(u8, field.key, "posX")) {
|
||||
command.posX = std.fmt.parseInt(u32, field.value, 10) catch blk: { break :blk 0; };
|
||||
|
|
@ -194,20 +187,15 @@ pub fn configFieldHandler(_: std.mem.Allocator, field: ini.IniField) ?ini.IniFie
|
|||
|
||||
if (std.mem.startsWith(u8, field.header, "lbl:")) {
|
||||
const key = field.header[4..];
|
||||
const keyZ = temporary_allocator.dupe(u8, key) catch |e|
|
||||
std.debug.panic("CustomCommands.labels: {} while duping key {s}", .{e, key});
|
||||
const keyZ = temporary_allocator.dupe(u8, key) catch "";
|
||||
if (!CustomCommands.labels.contains(keyZ)) {
|
||||
CustomCommands.labels.put(keyZ, .{
|
||||
.name = keyZ
|
||||
}) catch |e| {
|
||||
std.debug.panic("CustomCommands.labels: {} while putting for key {s}", .{e, key});
|
||||
};
|
||||
}) catch {};
|
||||
}
|
||||
if (CustomCommands.labels.getPtr(keyZ)) |label| {
|
||||
if (std.mem.eql(u8, field.key, "cmd")) {
|
||||
label.cmd = temporary_allocator.dupe(u8, field.value) catch |e| {
|
||||
std.debug.panic("CustomCommands.labels: {} while duping command '{s}'", .{e, field.value});
|
||||
};
|
||||
label.cmd = temporary_allocator.dupe(u8, field.value) catch "";
|
||||
}
|
||||
if (std.mem.eql(u8, field.key, "posX")) {
|
||||
label.posX = std.fmt.parseInt(u32, field.value, 10) catch blk: { break :blk 0; };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue