import twmap
worked, thats where yours broke, right?= attr[..]
applied for like 6-2attr[:<ctrl+v>
https://zillyhuhn.com/cs/.1668327631.pngresult |= ((current_byte & mask) << shift) as i32;
should be
result |= (current_byte as i32 & mask) << shift;
[The Tale of Two Elitists]
Carpenter Elitist: *walking in IKEA to buy some meatballs*
Carpenter Elitist: (thinks to himself) Look at all these IKEA sheeples, a bunch of normies who don't have the skills to build their own furniture.
Carpenter Elitist: (thinks to himself) These people neither have the curiosity nor the initiative to learn basic woodworking.
Carpenter Elitist: (thinks to himself) I guess some people are simply like that, docile and apathetic.
Later
Carpenter Elitist: (to his son) Son, I have the IKEA meatballs you want. Were you able to fix the issue with my laptop?
Son, Linux Elitist: Yes. That issue will keep coming back. I can install Linux in your laptop to permanently resolve that issue.
Dad, Carpenter Elitist: I don't have time for that Linux you keep talking about. Windows works for me. Just fix it again later if the issue returns.
Son, Linux Elitist: (thinks to himself) I guess some people are simply like that, docile and apathetic.
Son, Linux Elitist: (thinks to himself) Some people neither have the curiosity nor initiative to learn basic information about operating systems.
Son, Linux Elitist: (thinks to himself) I hate to admit it but my dad is a normie and a Windows sheeple.
benchmark_quit
./DDNet "connect ger2.ddnet.org; benchmark_quit 3 foo.txt"
-1
in your videos, which means message to all-1
in your videos, which means message to all sv_motd
in your autoexec_server.cfgsv_motd
in your autoexec_server.cfg compile_commands.json
with cmake, I ran cppcheck like this:
cppcheck --project=compile_commands.json -DWIN64 --suppressions-list=cppcheck.supp --enable=all 2>cppcheck.log
With these suppressions in cppcheck.supp
:
```
cstyleCast
useStlAlgorithm
unusedFunction
variableScope
noExplicitConstructor
useInitializationList
noConstructor
uninitMemberVar
uninitMemberVarPrivate
uninitDerivedMemberVar
uninitStructMembe...let x;
if a == 2 {
x = 3;
} else {
x = 4;
}
mut
for parameters
why isnt everything a immutable reference (or simple type) and then if u add & its automatically mut
if u want a copy of the object as parameter it should be explicity mut
&
which is mut, or mut which is a copy
. rest is const anyway and the compiler should decide (edited)// pass by value
fn func(x: i32) {
// cant change x, its immutable
let y = x + 1;
}
// pass by value
fn func(mut x: i32) {
// can change, but its value is only changed locally (for the copy passed)
x = x + 1
}
fn func(x: &i32) {
// cant change x, its immutable
}
fn func(x: &mut i32) {
*x = *x + 1
}
mut
for reference is too verbose, as its more likely than a "real" copyint
it rarely useful anyway (edited)[T]
. Contiguous here means that elements are laid out so that every element is the same distance from its neighbors.child()
)
in C (edited)child()
)
in C (edited)#include <stdio.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <unistd.h>
#include <semaphore.h>
#define NUM_CHILDS 4
struct mmap_data
{
sem_t semaphore;
int pid;
};
void child(void *shared)
{
struct mmap_data *data = (struct mmap_data*)shared;
sem_wait(&data->semaphore);
data->pid = getpid();
sem_post(&data->semaphore);
}
int main(void)
{
void *shared = mmap(NULL,
sizeof(struct mmap_data),
PROT_READ | PROT_WRITE,
MAP_ANONYMOUS | MAP_SHARED,
-1, 0);
struct mmap_data *data = (struct mmap_data*)shared;
int err = sem_init(&data->semaphore, 1, 0);
printf("Parent pid is %d\n", getpid());
for(int i = 0; i < NUM_CHILDS; i++) {
if(fork() == 0) {
child(shared);
break;
}
}
sem_wait(&data->semaphore);
printf("pid:%d shared:%d\n", getpid(), *(int*)(shared + sizeof(sem_t)));
sem_destroy(&data->semaphore);
}
I was trying to see that all processes will edit the same addr valuechild()
is finishedsleep(1);
in the main func before the printf at the endl@debian:~/c$ ./mmap_ex
Parent pid is 4726
l@debian:~/c$ ./mmap_ex
Parent pid is 4815
pid:4815 shared:0
l@debian:~/c$ ./mmap_ex
Parent pid is 4844
pid:4845 shared:4845
#include <stdio.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <unistd.h>
#define NUM_CHILDS 2
int main(void)
{
void *shared = mmap(NULL,
sizeof(int),
PROT_READ | PROT_WRITE,
MAP_ANONYMOUS | MAP_SHARED,
-1, 0);
int not_shared = getpid();
*(int*)shared = getpid();
for(int i = 0; i < NUM_CHILDS; i++) {
if(fork() > 0)
break;
not_shared = getpid();
*(int*)shared = getpid();
}
sleep(1);
printf("pid:%d not_shared:%d shared:%d\n", getpid(), not_shared, *(int*)shared);
}
l@debian:~/c$ ./mmap_ex
pid 4989
pid 4990
pid 0
pid:4989 shared:4989
pid 4991
pid 0
pid 4992
pid 0
pid 0
sem_init(&data->semaphore, 1, 1);
for(int i = 0; i < NUM_CHILDS; i++) {
pid_t pid = fork();
printf("pid %d\n", pid);
if(pid == 0) {
child(shared);
break;
}
}
(edited)#include <stdio.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <unistd.h>
#include <semaphore.h>
#define NUM_CHILDS 4
struct mmap_data
{
sem_t semaphore;
int pid;
};
void child(void *shared)
{
struct mmap_data *data = (struct mmap_data*)shared;
sem_wait(&data->semaphore);
data->pid = getpid();
sem_post(&data->semaphore);
}
int main(void)
{
void *shared = mmap(NULL,
sizeof(struct mmap_data),
PROT_READ | PROT_WRITE,
MAP_ANONYMOUS | MAP_SHARED,
-1, 0);
struct mmap_data *data = (struct mmap_data*)shared;
int err = sem_init(&data->semaphore, 1, 0);
printf("Parent pid is %d\n", getpid());
for(int i = 0; i < NUM_CHILDS; i++) {
if(fork() == 0) {
child(shared);
break;
}
}
sem_wait(&data->semaphore);
printf("pid:%d shared:%d\n", getpid(), *(int*)(shared + sizeof(sem_t)));
sem_destroy(&data->semaphore);
}
I was trying to see that all processes will edit the same addr value pid:5403 shared:5403
pid:5404 shared:5404
pid:5402 shared:5404
pid:5405 shared:5405
pid:5406 shared:5406
data->pid = getpid();
sets his pid. at the end all processes shows this exact PID as it is "shared" memorystruct mmap_data
{
sem_t semaphore;
int pid;
};
void *shared = mmap(NULL,
sizeof(struct mmap_data),
PROT_READ | PROT_WRITE,
MAP_ANONYMOUS | MAP_SHARED,
-1, 0);
struct mmap_data *data = (struct mmap_data*)shared;
int err = sem_init(&data->semaphore, 1, 0);
printf("Parent pid is %d\n", getpid());
#include <stdio.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <unistd.h>
#define NUM_CHILDS 2
int main(void)
{
void *shared = mmap(NULL,
sizeof(int),
PROT_READ | PROT_WRITE,
MAP_ANONYMOUS | MAP_SHARED,
-1, 0);
int not_shared = getpid();
*(int*)shared = getpid();
for(int i = 0; i < NUM_CHILDS; i++) {
if(fork() > 0)
break;
not_shared = getpid();
*(int*)shared = getpid();
}
sleep(1);
printf("pid:%d not_shared:%d shared:%d\n", getpid(), not_shared, *(int*)shared);
}
sem_init is the equivalent of sem_open for unnamed semaphores.
#include <stdio.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <unistd.h>
#include <semaphore.h>
#define NUM_CHILDS 4
struct mmap_data
{
sem_t semaphore;
int pid;
int calls;
};
void child(void *shared)
{
struct mmap_data *data = (struct mmap_data*)shared;
sem_wait(&data->semaphore);
data->calls++;
data->pid = getpid();
sem_post(&data->semaphore);
}
int main(void)
{
void *shared = mmap(NULL,
sizeof(struct mmap_data),
PROT_READ | PROT_WRITE,
MAP_ANONYMOUS | MAP_SHARED,
-1, 0);
struct mmap_data *data = (struct mmap_data*)shared;
int err = sem_init(&data->semaphore, 1, 1);
printf("Parent pid is %d\n", getpid());
int forked = -1;
for(int i = 0; i < NUM_CHILDS; i++) {
forked = fork();
if(forked == 0) {
child(shared);
break;
}
}
if(forked == 0) {
printf("pid:%d shared:%d\n", getpid(), data->pid);
}
else {
int chd = 0;
while(chd < NUM_CHILDS) {
sem_wait(&data->semaphore);
chd = data->calls;
sem_post(&data->semaphore);
}
sem_destroy(&data->semaphore);
printf("i am the parent pid:%d\n", getpid(), data->pid);
}
return 0;
}
child()
printf
has an extra argument (edited)#include <stdio.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <unistd.h>
#include <semaphore.h>
#define NUM_CHILDS 4
struct mmap_data
{
sem_t semaphore;
int pid;
int calls;
};
void child(void *shared)
{
struct mmap_data *data = (struct mmap_data*)shared;
sem_wait(&data->semaphore);
data->calls++;
data->pid = getpid();
}
int main(void)
{
void *shared = mmap(NULL,
sizeof(struct mmap_data),
PROT_READ | PROT_WRITE,
MAP_ANONYMOUS | MAP_SHARED,
-1, 0);
struct mmap_data *data = (struct mmap_data*)shared;
int err = sem_init(&data->semaphore, 1, 1);
printf("Parent pid is %d\n", getpid());
int forked = -1;
for(int i = 0; i < NUM_CHILDS; i++) {
forked = fork();
if(forked == 0) {
child(shared);
break;
}
}
if(forked == 0) {
printf("pid:%d shared:%d\n", getpid(), data->pid);
sem_post(&data->semaphore);
}
else {
int chd = 0;
while(chd < NUM_CHILDS) {
sem_wait(&data->semaphore);
chd = data->calls;
sem_post(&data->semaphore);
}
sem_destroy(&data->semaphore);
printf("i am the parent pid:%d\n", getpid());
}
return 0;
}
here with forced orderprintf
has an extra argument (edited)twmap
: 0.9.0 contained a rather big bug where the Layer::shape
function had x and y mixed up. that is fixed, alongside its uses (somehow I managed to use it the correct wrong way multiple times).
apart from the fixes there should not be any breaking changes with 0.9.1, but some nice additions from @Ryozuki
twmap-tools
: twmap-edit
wasn't working properly because of the mentioned bug, everything should work again
twmap-py
: the to_mesh
method on tiles layers now works again, it was broken for a while (also the release was necessary to fix the mentioned bug)
twmap-blender
: the add-on now automatically downloads the twmap python module with pip, if it isn't installed (release: https://gitlab.com/Patiga/twmap-blender/-/releases/v0.3.0)